Script Runner create sub-task if custom field is changed

Dylan Secreast October 8, 2015

I have a radio button custom field named "Incident Priority" with options: Priority 1, Priority 2, Priority 3, and Priority 4, wanting to create a new sub-task if the custom field is changed after issue creation. I have been attempting to do the following within Script Runner's built-in "Create a sub-task" script with no success:

changeItems.any {
    it.field == 'Incident Priority' && it.oldstring == "Priority 1" && it.newstring == "Priority 2"
}

This post function is currently in the create transition, listed after "Re-index an issue to keep indexes in sync with the database" and before "Fire a Issue Created event that can be processed by the listeners". Unfortunately, using JIRA's default priority field is not an option for this project.

 

Any input is greatly appreciated.

2 answers

1 vote
JamieA
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.
October 13, 2015

Exactly as Andrew says. You want Admin -> Script Listeners -> Create a subtask.

Under "expand examples" there are, well, examples for checking for field changes.

0 votes
AndrewB October 8, 2015

So after the issue is created - then you want to see if the priority custom field value gets changed, if so then create a sub-task. If you use a post function script on the create transition then it will never listen for changes to the issues after creation. It sounds like you'd want a event listener to listen for issueUpdated events, if the custom field priority was updated, then create a sub-task.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events