Hello Atlassian Community,
I am trying to get a custom field that is based on a result from 5 more custom fields values (Drop-down Single). In the past I did this with Power Custom Fields SIL but now it's paid and we don't want to spend 2000$ only for this field. We have Adaptavist Scriptrunner license and I am sure we can do it with it?
So I have 5 custom fields with options: High, Medium, Low. Each of them represent a number (3,2,1).
The goal is that my custom field will show a value based on the SUM of these fields.
This should be really simple if you look at my code:
def damage = getCustomFieldValue("Damage")
def reproducibility = getCustomFieldValue("Reproducibility")
def exploitability = getCustomFieldValue("Exploitability")
def affectedUsers = getCustomFieldValue("Affected users")
def discoverability = getCustomFieldValue("Discoverability")
def damagerating;
def reproducibilityrating;
def exploitabilityrating;
def affectedUsersrating;
def discoverabilityrating;
def scoreTotal;
if ( damage == "Low" ){
damagerating = 1;
} else if ( damage == "Medium" ){
damagerating = 2;
} else if ( damage == "High" ){
damagerating = 3;
}
if ( reproducibility == "Low" ){
reproducibilityrating = 1;
} else if ( reproducibility == "Medium" ){
reproducibilityrating = 2;
} else if ( reproducibility == "High" ){
reproducibilityrating = 3;
}
if ( exploitability == "Low" ){
exploitabilityrating = 1;
} else if ( exploitability == "Medium" ){
exploitabilityrating = 2;
} else if ( exploitability == "High" ){
exploitabilityrating = 3;
}
if ( affectedUsers == "Low" ){
affectedUsersrating = 1;
} else if ( affectedUsers == "Medium" ){
affectedUsersrating = 2;
} else if ( affectedUsers == "High" ){
affectedUsersrating = 3;
}
if ( discoverability == "Low" ){
discoverabilityrating = 1;
} else if ( discoverability == "Medium" ){
discoverabilityrating = 2;
} else if ( discoverability == "High" ){
discoverabilityrating = 3;
}
scoreTotal = (damagerating + reproducibilityrating + exploitabilityrating + affectedUsersrating + discoverabilityrating)
if (scoreTotal >= 10) {
return "High";
}
if (scoreTotal >= 5) {
return "Medium";
}
if (scoreTotal < 5) {
return "Low";
}The field is not even show in the Screen where it's configured. When I try the Preview I get"
Result: null
Log:
2019-08-09 09:35:49,144 ERROR [runner.ScriptFieldPreviewRunner]: ************************************************************************************* 2019-08-09 09:35:49,144 ERROR [runner.ScriptFieldPreviewRunner]: Script field preview failed for field that has not yet been created groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getCustomFieldValue() is applicable for argument types: (java.lang.String) values: [Damage] at Script163.run(Script163.groovy:1)
Highly appreciate any help