The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

CPrime Power Script Listener Not executing on Event

Jason G
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 19, 2018

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.

 

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Jonathan Muse {Appfire}
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 Champions.
April 24, 2018

Hi @Jason G, unfortunately, Tempo fields are not supported at this time since their API is rather closed off. That is probably why it appears that your listener is not firing.

Alos, I noticed that in the first line the value is given as if it were an array but the variable is not defined as such:

string managedProjects = {"CORETM"};

Should be

string [] managedProjects = {"CORETM"};

Or

string managedProjects = "CORETM";

This may have something to do with it as well.

Thanks