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

This widget could not be displayed.

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

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

This widget could not be displayed.

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 Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

212 views 3 0
Join discussion

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