Groovy script to add/remove watchers on the basis of Priority


I need a groovy script for the below situation:

1. Without having to do a workflow transition, if the ticket is edited and the priority is moved up (After it is vetted) to critical or serious…add the appropriate critical or serious user to watcher

2. If an issue us lowered from critical to serious…remove the critical user as watch and add the serious user

3. If an issue is lowered from either critical or serious to Important or minor…remove the critical or serious user from watcher
I need the script as i am not well versed with the groovy scripting.

1 answer

This widget could not be displayed.
Henning Tietgens Community Champion Feb 25, 2014

I'm sorry but I think it's not a good idea to use such scripts without any knowledge in scripting JIRA. You have to maintain all of your scripts if something goes wrong or if you want to update JIRA.

In your case you should implement a listener which looks for changes to the priority field and than adapt the watchers accordingly. Look into the documentation of Script Runner on how to write a listener, look into the JIRA API on how to read issue fields and add/remove watchers.

how can I check if priority has been moved from critical to serious. I mean i can check for priority of an issue

if((priority.equals("2")) || (priority.equals("1"){

//Assign to watchers who need for showstopper




I am not able to figure out on how could I check if the priority has been changed from Critical to Serious.

Henning Tietgens Community Champion Feb 26, 2014

You can get the old values from the changelog like this.

event?.changeLog?.getRelated('ChildChangeItem')?.findAll{ it.field=='priority' }?.each {
    previousPriority = it.oldvalue
    // ...

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

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