Two Factor Priority Fields

Bryan Virgin November 23, 2015

I would like to create a new priority field that is automatically calculated from two other single dropdown fields or a single cascading dropdown field (whichever is easier). The two factors would be below Frequency (4 options) and impact (12 options), and based on those inputs the new priority would be calculated. 

 

Is this possible using Script Runner?

3 answers

4 votes
Jamie Sawyer (Adaptavist) November 24, 2015

Hi Bryan,

Taking Gabrielle and Doug's comments a little further, the code you'll want will look something like this:

def frequency = getCustomFieldValue("Frequency").getValue()
def impact = getCustomFieldValue("Impact").getValue()
 
if (frequency && impact) {
	switch (frequency) {
		case "First Frequency":
			switch (impact) {
				case "First Impact":
						return "something"
				case [...]
			}
		case [...]
	}
}

Obviously, replacing the switch/case statements with whatever logic you're after (I include those as a simplistic example).  If you have any other questions, please post here.

Bryan Virgin December 4, 2015

Hi Jamie, Thank you so much for the information. This is very helpful. I used your Query in the inline script field for the "True Priority" Script field. I am not able to return anything. The "True Priority" field doesn't even show on the issue even though it has been added to the screen. Here is the Query I am using, for only one case to test. def frequency = getCustomFieldValue("Frequency").getValue() def impact = getCustomFieldValue("Impact").getValue() if (frequency && impact) { switch (frequency) { case "Always": switch (impact) { case "Security: In Production": return "P1" } }

Bryan Virgin December 17, 2015

Hi Jamie, Do you have any insight on this?

1 vote
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 23, 2015

The "Scripted Field" can do this. Alternatively, a "Post function" to "Set Field Value to constant or Groovy expression" can do that too with Conditional Execution based on what you need.

0 votes
Doug Swartz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 23, 2015

As Gabriella said - Yes this is possible with a Script Runner scripted field. We do something very similar.

Suggest an answer

Log in or Sign up to answer