can I run a script to multiply 3 numbers if the 3 number's fields are either radio buttons or select list? I need to restrict what values can be entered for risk_severity, risk_probability and risk_detectability.
I tried making one of the fields a radio button then ran my script (in scripted field) and am getting the following message.
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.customfields.option.LazyLoadedOption.multiply() is applicable for argument types: (java.lang.Double) values: [3.0]
def Risk_Severity = getCustomFieldValue("Risk Severity - radio") def Risk_Probability = getCustomFieldValue("Risk Probability") def Risk_Detectability = getCustomFieldValue("Risk Detectability") if (Risk_Severity) { return (Risk_Severity * Risk_Probability) * Risk_Detectability } else { return null }
The value is the name of the option - is it definitely "1"?
Why don't you log it using assert in condition tester: https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-PowerAssertions
Then you can see exactly why it's not equal to that.
I tried this in my condition and am getting the error below.
assert cfValues['Risk Severity'].value == '1' || cfValues['Risk Severity'].value == '2' || cfValues['Risk Severity'].value == '3'
The JIRA server was contacted but has returned an error response. We are unsure of the result of this operation.
Close this dialog and press refresh in your browser
However, I'm not going to be able to use this unless I can also ONLY run the validator if the issue type = Bug. So I guess I'm back to my original question which is whether or not I can multiply values in a scripted field if the variable fields are radio button or select list?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version are you using - must be an old one?
> multiply values in a scripted field if the variable fields are radio button or select list?
Yes, you just need to cast them to Integers.
(cfValues['Some Field'].value as Integer) * 2 > 10
but check for nulls.... test with issues without the field set at all as well as with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is my draft script. Do I add .value as Integer to each field in the return line?
def Risk_Severity = getCustomFieldValue("Risk Severity")
def Risk_Probability = getCustomFieldValue("Risk Probability")
def Risk_Detectability = getCustomFieldValue("Risk Detectability")
if (Risk_Severity) {
return (Risk_Severity * Risk_Probability) * Risk_Detectability
}
else {
return null
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
apologies for the basic questions. I do most of our JIRA administration but I am not a developer.
we are using JIRA 5.0.1 (planning to upgrade to 6.0.8 next week)
script runner plugin is version 2.0.4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I can't use radio button or select list to restrict what the user can enter, I would like to add a condition to a workflow transition. I tried adding a condition type "simple scripted validator" and tried the following sample condition
cfValues['Risk Severity'].value == '1'
It isn't working because it displays my chosen error message even if I have entered a 1 into the Risk Severity field.
I need the condition to display a message "Risk Severity can only be 1, 2, or 3. (1=Low, 2=Med, 3=High)" if the Risk Severity is not 1,2,or3.
Can someone help me with the syntax?
Thank you,
Jeannette
p.s. - also, is there a way to have the condition only run if Issue Type = Bug without having to create a separate workflow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.