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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Hipchat

Moving from Hipchat to Stride? Here’s what you’ll love

Heya, Hipchat friends! We’re so happy you’re checking out   Stride. Whether you know it or not, you have been instrumental in making Stride come to life. Every feature, design, and functionality...

56 views 2 6
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