Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner listener: update priority based on two other fields Edited

Hello the community,


I try to find a solution on my listener script.

I have two field urgency and impact. I would like to change the priority if one of these fields is updated.


I write the following script but I don't know how to do the update of priority fields.

Could you help me to find the solution?

The script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.customfields.option.Option
import org.apache.log4j.Level

def issue = event.issue as Issue;

def urgency = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("[IMP] Urgency")
def impact = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("[IMP] Impact")
def valueUrgency = issue.getCustomFieldValue(urgency)
def valueImpact = issue.getCustomFieldValue(impact)

log.debug "impact value " + valueImpact;
log.debug "urgency value " + valueUrgency;

if (valueImpact == "High" && valueUrgency == "Medium"){

} else if (valueImpact == "Medium" && valueUrgency == "High"){

} else if (valueImpact == "Medium" && valueUrgency == "Medium"){

} else if (valueImpact == "High" && valueUrgency == "High"){

} else {



Thank you a lot for your help.


Mickael O.

1 answer

Can you try this? Set the proper issue key.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def priorities = ComponentAccessor.getComponent(PriorityManager).priorities

//define the existing priorities (Minor, Major,...)

def majorPriority = priorities.findByName("Major")
def minorPriority = priorities.findByName("Minor")

IssueManager issueManager = ComponentAccessor.issueManager
String issueKey = 'TEST-1'

def issue = issueManager.getIssueObject(issueKey)

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Suggest an answer

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

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,184 views 8 28
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you