Project

General

Profile

Actions

Defect #16932

closed

saving custom_fields

Added by Brett Dudo about 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Custom fields
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

I'm using redmine 2.3.1devel

using ruby's ActiveResource::Base to find an issue, and I can update the status fine, but the custom_fields seem to elude me.

issue = Issue.find(issue_id)
return unless issue
ready = issue.custom_fields.select{|i| i.name == 'Ready for testing'}.first
deployed_to = issue.custom_fields.select{|i| i.name == 'Deployed to'}.first
issue.subject = 'test'
ready.value = '1' #['0', '1']
deployed_to.value = "staging" #['staging', 'production']
issue.save

This updates the subject fine, but the custom fields are not updated in redmine. http://stackoverflow.com/questions/23749065/redmine-saving-of-custom-fields-from-ruby-api (i created this ticket over at SO, too).

Is this taken care of in a newer version? Am I just doing something wrong? Thanks for the help!

Actions #1

Updated by Brett Dudo about 11 years ago

to that extent... how do I interact with the status object?

"status"=>
     #<Redmine::Issue::Status:0x007f9df2cf5098
     @attributes={"id"=>5, "name"=>"Closed"},
     @persisted=false,
     @prefix_options={}>,
Actions #2

Updated by Jean-Philippe Lang about 11 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

You need to use #custom_field_values= in order to update custom field values:

# deployed_to_custom_field_id is the id of your "Deployed to" custom field
issue.custom_field_values = {deployed_to_custom_field_id => "staging"}
issue.save
Actions

Also available in: Atom PDF