We have a business requirement where we want to propagate a custom field from an epic onto all issues with a link of "Epic-Story Link" and from them onto any sub-tasks.
To do this we intend to use a Listener script associated with the "Issue Updated" system event
and a second listener associated with a custom event specific to the update of the field in question
The details of the scripts are below
Listener 1
s
string managedProjects = {"CORETM"};
string tempoAccountFieldName = "Account";
string epicLinkFieldName = "Epic Link";
string epicLinkFieldID = "customfield_11131";
string tempoAccountFieldID = "customfield_12130";
string myepickey;
boolean raiseEvent = false;
JFieldChange [] changes;
print("tempoAccountUpdateEventEmitterListener fired for " + key);
if ( elementExists(managedProjects, project) ) {
changes = lastIssueChanges(key);
for(number i = 0; i < size(changes); i++) {
if (changes[i].field == epicLinkFieldName) {
myepickey = %epicLinkFieldID%;
if (isNotNull(myepickey)) {
%tempoAccountFieldID% = %myepickey%.%tempoAccountFieldID%;
print("tempo account field copied from " + myepickey + " on to " + key);
raiseEvent = true;
}
}
if (changes[i].field == tempoAccountFieldName) {
raiseEvent = true;
}
}
}
if (raiseEvent) {
print("Tempo Account Updated event fired for " + key );
raiseEvent("Tempo Account Updated", key, currentUser());
}
Listener 2
string linkTypeName = "Epic-Story Link";
string epicIssueType = "Epic";
string tempoAccountFieldID = "customfield_12130";
string [] linkkeys;
if (issueType == epicIssueType) {
linkkeys = allLinkedIssues(key, linkTypeName);
} else {
linkkeys = subtasks(key);
}
for (string linkkey in linkkeys) {
print("tempo account field copied from " + key + " on to " + linkkey);
%linkkey%.%tempoAccountFieldID% = %tempoAccountFieldID%;
}
Listener1 is associated with the system Event "Issue Updated" and Listener2 is associated with the custom event "Tempo Account Updated".
Currently neither script is executing. Any assistance would be greatly appreciated.