Copy value from one custom filed to another when the value of the first custom field is changed

Nadica Gaber November 16, 2017

Hi All,

 

We need to copy the value from CF 1 to CF 2 as soon as the CF 1 value is changed.  Adding a post function for copying the values does not meet our needs. Can this be done with a script?

Regards,

Nadica

2 answers

7 votes
Johnson Wang November 22, 2017

Hey @Nadica Gaber,

I agree that the POST function doesn't really give you the ideal solution you're looking for.

This can definitely be done with a script, and I'd recommend an add-on like Power Scripts.

We've put together a quick tutorial video showing exactly how to copy a field value from one field to another as soon as the first field's value is changed. You can even copy and paste the SIL script to see how it works.

Hope this helps!

Johnson

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

Hello,

Which plugin do you have to write a script? If you have Adaptivist Scriptrunner, you could write a listener. The listener would catch the update issue event and checked if the required field changed. If it ischanged, then you could change the other field.

Read more information about listeners here:

https://scriptrunner.adaptavist.com/5.0.0/jira/listeners.html#_custom_listeners

But you are not limited to Adaptivist scriptrunner, there are must be other plugins with such functionality

Mandia December 26, 2018

Hi @Alexey Matveev

I have the similar need as @Nadica Gaber. But I want to implement that if parent's Due date field has changed the open subtask's due date change to blank by using SIL listeners

Could you please give me a demo code?

 

Thanks,

Mandia

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 27, 2018

Hi @Mandia

It would be better if you asked a new question and mention me in this new question. But anyway here is the solution :)

JFieldChange [] changes = lastIssueChanges(key);
boolean flag = false;
for(number i = 0; i < size(changes); i++) {
  if (changes[i].field == "CF1") {
    flag = true;
  }
}

if (flag) {
  #{CF2} = #{CF1;
}
Mandia December 27, 2018

Thanks for replying me !

Here is my new question :https://community.atlassian.com/t5/Jira-Software-questions/When-Parent-Task-Due-date-changed-open-sub-task-due-date-change/qaq-p/969271#M38530

I saw your code, I want to implement when the parent task due date changed then the open sub-task 's due date auto change to blank. not copy value

 

Thanks,

Mandia

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 27, 2018

You are most welcome! Done :)

Suggest an answer

Log in or Sign up to answer