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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Change Priority Based on Single List choice



I found this script and I am trying to adapt it to my needs and add it as a post function to the create step in my workflow so that when an issue is logged, it looks at a field and then updates the priority accordingly.

Custom Field - Cyber Incident Categorisation with the following options:
Account Compromise - P1
Host Compromise - P2
Phishing - P3
Denial of Service - P4
Extortion (Ransomware)  - P5
Insider Threat - P1
Data Loss & Compromise - P2


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

final customFieldName = "Cyber Incident Categorisation"

//Get custom field issue with this name
def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField: "Could not find custom field with name $customFieldName"

def customFieldVal = issue.getCustomFieldValue(customField) as LazyLoadedOption

//Create priorities
def priorities = ComponentAccessor.getComponent(PriorityManager).priorities

def highestPriority = priorities.findByName("P1")
def highPriority = priorities.findByName("P2")
assert highestPriority && highPriority: "One ore more selected priorities doesn't exist"

--- I actually need this to go up until P5 so would the additional priorities need to be added on and defined as such as medium, lower, lowest?

 //Assign priority depending on the custom field value
switch (customFieldVal?.value) {
case "Account Compromise":
case "Host Compromise":
log.debug "No need to change the priority"


Any help would be appreciated.



1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Jan 26, 2022

Hello @Drishti Maharaj ,

I just tried your script. It is working fine, I only had to add this line at the end to update the issue : 

ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getUserManager().getUserByKey('user_key'), issue, EventDispatchOption.DO_NOT_DISPATCH, false);

Of course you will need to map all the priorities in your switch but that does not seem to be the issue.

Let me know if that helped.

Hi @Antoine Berry , thank you for taking the time to reply, if I add the additional script from you, the following error occurs:

Screenshot 2022-01-27 082910.png

Hi @Antoine Berry , I managed to figure out what was wrong :)

Just needed this at the top:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption

and it worked perfectly! 

Thank you so much!

Like Antoine Berry likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events