Script Runner create sub-task if custom field is changed

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

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

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

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

66 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you