Please bear with me - I am very new to groovy and haven't coded anything in years....
We have two custom dropdown fields (Technical Certainty and Definition Certainty), where users can select “High”, “Medium”, or “Low” :
When either of those values change, we want ScriptRunner to update a “Confidence Level” text field based on the combination of Technical and Definition Certainty.
Regardless of the values, “Confidence Level” is set to “Undetermined”. In the script, I returned the values of all three fields and found that it is returning more than just value for the Technical and Definition Certainty fields. I'm not exactily sure what this is - is it from rest api? I just want the value shown in bold.
The scripted field ran successfully.
"[self:https://******-sandbox.atlassian.net/rest/api/2/customFieldOption/10113, value:Medium, id:10113];
[self:https://******-sandbox.atlassian.net/rest/api/2/customFieldOption/10118, value:High, id:10118];
Undetermined"
Is there something I am missing to pull only the value? Or is there something I need to do to convert or parse it? Thoughts?
Thank you for your help!
Here is the script:
def issueKey = issue.key
def TCName = 'Technical Certainty'
def DCName = 'Definition Certainty'
def CLValue = 'Confidence Level'
def TCValue = Issues.getByKey(issueKey).getCustomFieldValue(TCName)
def DCValue = Issues.getByKey(issueKey).getCustomFieldValue(DCName)
def val = [TCValue, DCValue]
switch (val) {
case {it == ['Low', 'Low']}:
CLValue = '50%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['Low', 'Medium']}:
CLValue = '60%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['Medium', 'Low']}:
CLValue = '60%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['Low', 'High']}:
CLValue = '70%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['High', 'Low']}:
CLValue = '70%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['Medium', 'Medium']}:
CLValue = '70%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['Medium', 'High']}:
CLValue = '80%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['High', 'Medium']}:
CLValue = '80%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
case {it == ['High', 'High']}:
CLValue = '90%'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
default:
CLValue = 'Undetermined'
"${TCValue}; ${DCValue}; ${CLValue}";
break;
}