Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to use 2 custom fields to determine a scripted field value using ScriptRunner Script Fields

Amanda Tippett
April 13, 2023

Hi,

I have 2 custom fields configured as Select List (single choice) which is completed on a screen during the workflow's 1st transition.  These 2 fields are used to determine the 3rd custom field which is configured as a Scripted Field.

Below is the script however when using the PREVIEW option, it always returns a NULL result even though the Preview Issue Key used has values that are in the def values section.  Configure Context and Screens has been completed.

I have also created a ticket using both scenarios in the def values section however the scripted field is not displaying on the screen configured.

Would greatly appreciate any advice on how to rectify this issue.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

int consequenceId = 17301
int likelihoodId = 17300
int targetFieldId = 17302

def consequence = getFieldById("customfield_" + consequenceId)
def consequenceValue = consequence.getValue()
def likelihood = getFieldById("customfield_" + likelihoodId)
def likelihoodValue = likelihood.getValue()
def targetField = getFieldById("customfield_" + targetFieldId)

def values = [[Consequence:"Severe", Likelihood:"Certain", TargetValue:"High"],
[Consequence:"Minimum", Likelihood:"Rare", TargetValue:"Low"]]

def targetFieldValue = values.find { it.Consequence == consequenceValue &&
it.Likelihood == likelihoodValue}?.TargetValue
if (targetFieldValue != null){
targetField.setFormValue(targetFieldValue)
}

2 answers

0 votes
Graeme Binnington
June 11, 2018

Ok, issue was that my colleague had setup the board - I assumed it was the Scrum board, but it wasn't. It was a new Agility Board - Jira should perhaps make this a little clearer as it would have saved some time. 

Moses Thomas
Community Champion
June 11, 2018

@Graeme BinningtonWe have some descriptive  info  about these boards,  you  may take some time to  read it to help  you also  to  see more differences  between  these boards.

ttps://www.atlassian.com/agile/kanban

https://www.atlassian.com/agile/scrum

 

Best!

0 votes
Moses Thomas
Community Champion
June 7, 2018

@Graeme BinningtonJust  create a scrum  board in  this project,   an  epic  issue doesn't  need to  have  the issue type epic, it can  be other issue types, if you want an "epic" to  have issue type epic, then add it in issue type scheme.

 

Best!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events