Html bobswift |
---|
<iframe width="560" height="315" src="https://www.youtube.com/embed/zUypjUQXf24" frameborder="0" gesture="media" allowfullscreen></iframe> |
Bitbucket file macro |
---|
showLineNumbers | true |
---|
title | CopyValueOnChange.sil |
---|
url | https://bitbucket.cprime.io/projects/CAP/repos/sil-script-library/raw/Event_Listeners/CopyValueOnChange.sil?at=refs%2Fheads%2Fmaster |
---|
syntaxHighlighting | JavaScriptThis script runs as a listener to the issue update event. Should the value of the Color field (customfield_10712) change from the previous value the script will update the custom field called Color 2 (customfield_10717).Updated Script
Code Block |
---|
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;
}
} |
Old Script
Code Block |
---|
//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;
}
} |