Closed lublasco closed 2 years ago
Hi,
Use this code in AFTER SAVE:
if !parent.nil? && custom_field_value(180).to_s == "Value11"
self.parent.custom_field_values = { 154 => "Value21"}
self.parent.save_custom_field_values
end
I hope it helps!
Awesome @AirTibu , worked like a charm! Thank you very much for your quick help :)
@AirTibu Hi!
I have one question, why there is 154 at second row?
@AirTibu I want to change a custom field (user) based on issue status, but it doesn't work, here is my code:
if @issue.status_id == 2
@issue.custom_field_value_2 = @assigned_to
end
i tried to change the code to this:
if @issue.status_id == 2 @issue.custom_field_values = { 2 => @issue.assigned_to} end
it still not work.
could you help me?
@AirTibu Hi!
I have one question, why there is 154 at second row?
Hi,
180 is my custom field ID. You should change to 2 (according to your first mail, this is the subtask custom field)
154 is also my custom field ID, you should change to 1
@AirTibu I want to change a custom field (user) based on issue status, but it doesn't work, here is my code:
if @issue.status_id == 2 @issue.custom_field_value_2 = @assigned_to end
i tried to change the code to this:
if @issue.status_id == 2 @issue.custom_field_values = { 2 => @issue.assigned_to} end
it still not work.
could you help me?
Hi,
Use this code in AFTER SAVE:
if self.status_id=='2'
self.custom_field_values = {'2' => assigned_to_id.to_s}
self.save_custom_field_values
end
I hope it helps!
@AirTibu I want to change a custom field (user) based on issue status, but it doesn't work, here is my code:
if @issue.status_id == 2 @issue.custom_field_value_2 = @assigned_to end
i tried to change the code to this: if @issue.status_id == 2 @issue.custom_field_values = { 2 => @issue.assigned_to} end it still not work. could you help me?
Hi,
Use this code in AFTER SAVE:
if self.status_id=='2' self.custom_field_values = {'2' => assigned_to_id.to_s} self.save_custom_field_values end
I hope it helps!
thanks a lot!
It doesn't work at first, i tried to change some parts and put following code in BEFORE SAVE:
if @issue.status_id==2 @issue.custom_field_values = {'2' => assigned_to_id.to_s} end
and it perfectly work.
thanks again!
Hi,
Yes, there was indeed a flaw in it. The status ID should not have been put as an apostrophe. The self and @issue mean the same thing, it can't be a mistake.
I'm sorry, I wrote my last message half asleep.
If you want to update a custom field in the AFTER SAVE section, you only need to save the custom field:
self.save_custom_field_values
Would you close the issue if the problem is resolved? Thanks!
Parent issue custom field id=1 Parent issue custom field 1 values= Value11, Value12
Subtask custom field id= 2 Subtask custom field values= Value21, Value22
Hi, I've achieved one part of the requisite (to close parent task if subtask is closed), but need help to set the parent issue custom field to Value11 if the subtask's custom field is set to Value21.
-- before save --
--after save --
It would be great if anyone could complete the above code. Thank you very much in advance.