Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Change Priority via Script Runner Listener not working on transition screens Edited


We have a script runner listener which changes the Priority based on two custom fields; Impact and Urgency.

When Impact and Urgency are changed either via quick edit or edit mode for the issue it works, and Priority is updated. However when changing Impact or Urgency on a transition screen the Priority is not changed. Even when the Priority field is on the screen (in case that would matter).

The script:

package pfa.listener.ImpactUrgency

import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueInputParametersImpl

class TaskVersionListener extends AbstractIssueEventListener {
Category log = Category.getInstance(TaskVersionListener.class)

void workflowEvent(IssueEvent event) {
MutableIssue issue = (MutableIssue) event.issue
def impactMap=["Low":3, "Medium":2, "High":1];
def urgencyMap=["Low":3, "Medium":2, "High":1];

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField cf_impact = customFieldManager.getCustomFieldObject("customfield_10577")
CustomField cf_urgency = customFieldManager.getCustomFieldObject("customfield_10578")

String impact = new String(issue.getCustomFieldValue(cf_impact).toString().getBytes(), "UTF-8")
String urgency = new String(issue.getCustomFieldValue(cf_urgency).toString().getBytes(), "UTF-8")

def calculatedPriority=0
if (impact != 'null' && urgency != 'null'){
calculatedPriority = impactMap[impact] + urgencyMap[urgency] -1
calculatedPriority = 4

def priority = calculatedPriority.toString()
def constantsManager = ComponentAccessor.getConstantsManager()
def issueService = ComponentAccessor.getIssueService()
def issueInputParameters = new IssueInputParametersImpl()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


def updateValidationResult = issueService.validateUpdate(user,, issueInputParameters)

if (updateValidationResult.isValid()) {
issueService.update(user, updateValidationResult)
} else {
log.warn updateValidationResult.errorCollection.errors

We are running JIRA 7.3.4 and Script Runner 4.3.19.

The listener is set up to the following Events: Issue Created and Issue Updated. I tried adding Generic Event (as that is what is fired by the workflow transition) but with no luck.


Further investigation, has shown that the Listener IS fired. I can log output and I can even see that I can read values out of the custom fields. The only thing missing is that the Priority field is not updated.


Any suggestions?



2 answers

0 votes
Andy Heinzer Atlassian Team Sep 26, 2017

Since we know that the issue created and Issue updated events are working here, I would suggest trying to edit the workflow itself.  You can specifically change the post function that is associated with this transition.

If you edit that workflow, go to post functions, then edit the Fire a Generic Event, you can change this to a value such as Issue Updated.




You can then publish this workflow, at which point the use of that transition should then fire off the issue updated event, and in turn trigger your script.

Since the execution of this transition is expected to change the status of the issue, I can't really think of any side-effects for this kind of workflow change.


Thank you for the suggestion - I tried to set the workflow transition to invoke an Issue Updated event instead, but get the same result. Priority is not updated.

Further investigation, has shown that the Listener IS fired. I can log output and I can even see that I can read values out of the custom fields. The only thing missing is that the Priority field is not updated.

(I'll update my original question with this information as well).



Are there any other ideas to solve the problem? Because I'm in the same spot.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

221 views 7 7
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