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

Changing issue priority through a listener on issue update

Steven Mustari May 10, 2016

I have the following code that is working as a post function to update issue priority based on a custom field. I am trying to make this process dynamic and occur whenever the issue is updated. This is what I have so far:


import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Category"[UpdateParentPriority] Script fired");

MutableIssue mutableIssue = (MutableIssue) issue;
ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customField = customFieldManager.getCustomFieldObject("customfield_11608");     // 11608 = Category Priority

def customFieldValue = getCustomFieldValue(customField);

switch (customFieldValue) {
    case "2":
        mutableIssue.setPriorityId("10000");    // 2 = Trivial"[UpdateParentPriority] Priority 2 set to Trivial");
    case "3":
        mutableIssue.setPriorityId("10001");    // 3 = Lowest"[UpdateParentPriority] Priority 3 set to Lowest");
    case "4":
        mutableIssue.setPriorityId("10002");    // 4 = Low"[UpdateParentPriority] Priority 4 set to Low");
    case "6":
        mutableIssue.setPriorityId("10003");    // 6 = Medium"[UpdateParentPriority] Priority 6 set to Medium");
    case "8":
        mutableIssue.setPriorityId("10004");    // 8 = High"[UpdateParentPriority] Priority 8 set to High");
    case "9":
        mutableIssue.setPriorityId("10005");    // 9 = Highest"[UpdateParentPriority] Priority 9 set to Highest");
    case "12":
        mutableIssue.setPriorityId("10006");    // 12 = Critical"[UpdateParentPriority] Priority 12 set to Critical");
    default:"[UpdateParentPriority] ERROR - unable to set issue priority");

// Update Issue
ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getUserUtil().getUserObject('automation'), mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);


When I run this code as a listener I get an error:


2016-05-10 18:37:51,586 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.CustomFieldImpl) values: [Category Priority]


The scripted field being called is an SIL Scripted field that is being calculated.. Is this the reason I am throwing this error?

2 answers

1 accepted

1 vote
Answer accepted
Steven Mustari May 11, 2016

I think my issue was that since this is a listener, there is no value assigned to "issue" by default. I added the following and it seems to have resolved it:


def issue = event.getIssue();
0 votes


try "issue.getCustomFieldValue(customField);

getCustomFieldValue is a method of Issue  Interface:

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,095 views 13 15
Read article

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