I am trying to use a custom script in scriptrunner to evaluate a transition condition.
The key differentiator for this transition is the value of a custom field single select list - the list has two possible values (NOC or IT)
My code is below;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_11400")
def cFieldValue = issue.getCustomFieldValue(cField).toString()
log.warn("Field Value = "+cFieldValue)
if (cFieldValue != "IT") {
return true
} else {
return false
}
The log output is below;
2022-03-16 11:55:23,184+0000 [**ID removed] WARN [**Username removed] 715x519183x1 1vsq4ae [**IPs removed] /browse/CAB-472 [c.o.scriptrunner.runner.ScriptBindingsManager] Field Value = IT
2022-03-16 11:55:25,720+0000 [**ID removed] WARN [**Username removed] 715x519198x1 1vsq4ae [**IPs removed] /browse/CAB-517 [c.o.scriptrunner.runner.ScriptBindingsManager] Field Value = NOC
In two different browser windows, I have two issues open - one of each type that I am concerned with. The transition button should appear for one, but not the other. The button appears for both at all times.
For some reason, the string comparison in the IF statement for the above script does not work, and the transition always returns true (and therefore shows a button that I do not want all my users to see!)
I have tried different variations for string comparison in the IF statement,, such as;
"IT".equals(cFieldValue)
or
cFieldValue == "IT"
etc.
Server info grab as follows;
Jira Info
| Version | 8.13.9 |
| Build Number | 813009 |
| Build Date | Thu Jul 15 00:00:00 UTC 2021 |
| Build Revision | 6b24593e988639831c5b135a30425606cfbabcba |
| Installation Type | Standalone |
My Script Runner installation details as follows;
Version: 6.36.0
Support: Supported by vendor
App key: com.onresolve.jira.groovy.groovyrunner
Any help is appreciated...