Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Problem w/ Scriptrunner priority calculation based on impact/urgency when using browser back button

Robert P July 16, 2020

Hi!

We are automatically calculating a ticket's priority based on chosen impact + urgency. We have implemented a Scriptrunner behaviour according to these instructions: https://library.adaptavist.com/entity/set-priority-using-an-impact-urgent-matrix

The actual implementation looks as follows:

Initialiser script:

import com.atlassian.jira.issue.IssueFieldConstants

def priorityField = getFieldById(IssueFieldConstants.PRIORITY)
priorityField.setFormValue("Low")
priorityField.setReadOnly(true)
priorityField.setHidden(true)

Impact + Urgency Field script (identical):

import com.atlassian.jira.issue.IssueFieldConstants
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours

@BaseScript FieldBehaviours fieldBehaviours

def urgency_1 = "1-Critical - impact already occurred or imminent"
def urgency_2 = "2-High - impact by end of business day"
def urgency_3 = "3-Medium - impact within the next days"
def urgency_4 = "4-Low - no impact forecast"

def impact_1 = "1-Extensive (widespread, 500+ users affected, reputation or legal exposure for EvilCorp)"
def impact_2 = "2-Significant (large, 50+ users affected, business process interrupted)"
def impact_3 = "3-Moderate (limited, <50 users affected)"
def impact_4 = "4-Minor (local, <5 users affected)"

def prio_critical = "Critical (Highest)"
def prio_high = "High"
def prio_medium = "Medium"
def prio_low = "Low"

def priorityMatrix = [
(urgency_1): [
(impact_1): prio_critical,
(impact_2): prio_high,
(impact_3): prio_medium,
(impact_4): prio_low
],
(urgency_2): [
(impact_1): prio_high,
(impact_2): prio_high,
(impact_3): prio_medium,
(impact_4): prio_low
],
(urgency_3): [
(impact_1): prio_medium,
(impact_2): prio_medium,
(impact_3): prio_low,
(impact_4): prio_low
],
(urgency_4): [
(impact_1): prio_low,
(impact_2): prio_low,
(impact_3): prio_low,
(impact_4): prio_low
]
]

def priorityField = getFieldById(IssueFieldConstants.PRIORITY)

def impactFieldValue = getFieldByName("Impact").value as String
def urgencyFieldValue = getFieldByName("Urgency").value as String

def priority = prio_low

if (impactFieldValue && urgencyFieldValue) {
priority = priorityMatrix[urgencyFieldValue][impactFieldValue]
}

priorityField.setFormValue(priority)

 

This works fine unless you start using the browser's back button!

How to reproduce?

  • Create a new incident (in the user portal), select Impact and Urgency accordingly
    • A new ticket will be created with the correctly calculated priority
  • Now go back using the browser back button
  • Chose the lowest Impact and Urgency -> a Low prio ticket should be created
    • Instead, the new ticket is created with a priority of "High"
    • Sometimes, the priority field even shows on the form, even though it was set to hidden!

Any ideas what could be wrong here or how to troubleshoot this any further?

Updates:

  • I should mention we're on 5.6.2.1-jira8. I know that this is a fairly outdated version, but I have not found any bugs in the 5.x release notes that seem to relate to this problem.
  • I updated to 6.4.0-p5 but the problem is still there. 
  • The main problem seems to be that:
    • For some reason the Priority field shows (even though it should not) with a default value of "High"
    • Changing Impact + Urgency does not alter the Priority field
    • Thus, when the user submits the form the ticket is created with the incorrect Priority High

Thanks,
Robert

 

 

2 answers

0 votes
James Beagrie
Contributor
April 2, 2021

I managed to get a Urgency/Impact matrix to work with the following script.

It's applied to a behaviour where the priority field is read only and it's applied to both the Urgency and Impact fields.

import com.atlassian.jira.issue.IssueFieldConstants
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours

@BaseScript FieldBehaviours fieldBehaviours

def prio_critical = "P1"
def prio_high = "P2"
def prio_medium = "P3"
def prio_low = "P4"

def priorityMatrix = [
High : [
High : prio_critical,
Medium : prio_high,
Low : prio_medium,
],
Medium : [
High : prio_high,
Medium : prio_medium,
Low : prio_low,
],
Low : [
High : prio_medium,
Medium : prio_low,
Low : prio_low,
]
]

def priorityField = getFieldById(IssueFieldConstants.PRIORITY)
def impactFieldValue = getFieldByName("Business Impact").value as String
def urgencyFieldValue = getFieldByName("Urgency").value as String

if (impactFieldValue && urgencyFieldValue) {
def priority = priorityMatrix[urgencyFieldValue][impactFieldValue]
priorityField.setFormValue(priority)
}
0 votes
Guillaume September 28, 2020

Hello Robert,

Did you solve your pb?

I tried to reproduce your config but it was not successful for me.

If you have a few seconds, can you tell me if your script is working on the customer portal or in the create issue view ?

Regards,

Guillaume  

Robert P October 5, 2020

Hi Guillaume,

the issue occurs in the customer portal.

There's an open ScriptRunner defect: https://productsupport.adaptavist.com/browse/SRJIRA-4284

R

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events