Set Issue Priority in Jira Ticket

Hi,

I want to set issue priority in JIRA Ticket using groovy. We have a drop down list in JIRA ticket which is populated with a default priority once an issue is created. e.g "Priority 6".

With the help of groovvy I want to set the priority as "Priority 4".

I am able to get the issue priority  using the following code, but not able to set a new priority:

 

def priority=issue.priorityObject.name;

 

for setting:

 

issue.setPriority(new priority);

 

giving below error:

 

No signature of method: com.atlassian.jira.issue.IssueImpl.setPriority() is applicable fo
r argument types: (java.lang.String) values: [ Priority 4]
Possible solutions: setPriority(org.ofbiz.core.entity.GenericValue), getPriority(), setPriorityId(java.lang.String)
at Script480.run(Script480.groovy:66)

 

 

Pls suggest

 

 

2 answers

1 accepted

Hi Hemanshu,

Try something like 

def priority4 = "Priority 4"
def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == priority4}?.getId()

if (! priorityToSetId)
    log.debug "Could not find priority with name: $priority4"

issue.setPriorityId(priorityToSetId)

regards, Thanos

Hi Thanos, still not working:

This is my code:

def mail_priority=descArr[19].substring(9);//this is fetching string from a line. The string in this case is "Priority 4"

def final_priority=mail_priority.toString();//converting to String

def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == final_priority}?.getId();

if (! priorityToSetId)
log.debug "Could not find priority with name: $final_priority"

log.debug("Setting Priority");
issue.setPriorityId(final_priority);

 

 

pls suggest

I suppose this is a post function and is before the store issue step right ?

Also do you get any errors ? What about the debug messages in your logs ?

JIRA and SR versions ?

Hi Thanos,

 

This is part of a script which parses the content of an incoming email in JIRA to field values in Jira.

Hence this code is a post function which is part of transition:

*-------> Tier 1 New

this code:

def mail_priority=descArr[19].substring(9);//this is fetching string from a line. The string in this case is "Priority 4"

def final_priority=mail_priority.toString();//converting to String

def priorityToSetId = ComponentAccessor.getConstantsManager().getPriorityObjects().find {it.name == final_priority}?.getId();

if (! priorityToSetId)
log.debug "Could not find priority with name: $final_priority"

log.debug("Setting Priority");
issue.setPriorityId(final_priority);

 

 

is fecthing priority from the email(as Priority 4) and parsing the same with the "Priority" field in JIRA whose default value is set up as "Priority 6".

I cannot find any error in logs, but now after ticket creation, the priority field disappears.

Hence, there is no value set for "Priority" field in JIRA during ticket creation.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,798 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot