Need help for script debugging for groovy (Set Priority in context to issue.summary) Edited

We intend on setting The Priority Based on the summary for one of our SD's. For Example exemplarie mail subject "[...](Priority:1)[...]", which creates an issue with the summary [Ticketnumber][...](Priority:1)[...]. 
What we want to do:
1. get the issue.summery content
2. Look up the number after "Priority:"
3. Priority accordingly

Currently used code:

import com.atlassian.jira.issue.MutableIssue;

MutableIssue mutableIssue = (MutableIssue) issue;
String subject=issue.summary; //gets the summary
int indexfind; //Help Index to Find "Priority:"
indexfind=subject.indexOf("Priority:"); //finds 'P' of "Priority:"
String Prio=subject.charAt(indexfind+9); // finds the number of summary

switch (Prio){
case "1": mutableIssue.setPriorityId("2"); //set prio Critical
case "2": mutableIssue.setPriorityId("3"); //set prio high
case "3": mutableIssue.setPriorityId("4"); //set Prio Moderate
case "4": mutableIssue.setPriorityId("5"); //set Prio Low
default: mutableIssue.setPriorityId("5"); //sets to default od Low

The Script runner does not throw in exception but the intended use is not given. Couldt you please help me resolve this issue?

1 answer

1 accepted

1 votes

Answered on product support:

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issue = issue as MutableIssue
String subject = issue.summary //gets the summary
int indexfind //Help Index to Find "Priority:"
indexfind = subject.indexOf("Priority:") //finds 'P' of "Priority:"
String Prio = subject.charAt(indexfind+9) // finds the number of summary
switch (Prio)
case "1":
issue.setPriorityId("2") //set prio Critical
case "2":
issue.setPriorityId("3") //set prio high
case "3":
issue.setPriorityId("4") //set Prio Moderate
case "4":
issue.setPriorityId("5") //set Prio Low
issue.setPriorityId("5") //sets to default od Low
ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false);

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,788 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