Skip to end of banner
Go to start of banner

Copy a custom field value to another field when changed

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Current »

This script runs as a listener to the Issue Updated event. If the value of the Colors field (customfield_10712) changes, the script updates the Colors 2 custom field (customfield_10717).

Updated Script

struct _history {
  date changeDate;
  string value;
}

_history h = fieldHistory(key, "customfield_10712");
int hCount = arraySize(h);

if(hCount >= 3 ) {   
     if((h[hCount - 1] != h[hCount - 3]) || hCount == 3) {
        %key%.customfield_10717 = %key%.customfield_10712;
    }
}

Initial Script

//gets the history of the Color custom field
string [] h = fieldHistory(key, "customfield_10712");
int hCount = arraySize(h); //get the size of the history array

//If the value of the field is null the array size (hCount) will be 0
//If the value has been set only 1 time the array size (hCount) will equal 3
//If the value has been set more than once the array size (hCount) will be greater than 3
if(hCount >= 3 ) {
    
    //If the value in history has changed OR the value was only set once
    if((h[hCount - 1] != h[hCount - 3]) || hCount == 3) {
        %key%.customfield_10717 = %key%.customfield_10712;
    }
}
  • No labels