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
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)
}