Hi,
I have been trying to write a custom validation script to be executed on workflow transition. The purpose is to validate the contents of a custom field, of the label variety.
The first approach I took was in using the CustomFieldManager/LabelManager but realised that using that method I could only access the label contents prior to the transition being triggered. Therefore, any changes to the custom labels field made during the transition were missed.
My next approach has been to try and use the groovy script cfValues object to glean the contents changed during the transition. It was a bit of an assumption that cfValues could provide the access needed but it seemed the right direction. I proceeded to use an assertion to test it out but the assertion was not triggered having instead resulted in an error in the atlassian-jira.log (code and output snippets are below).
import java.util.Map
// intended to trigger in order to learn from assert results
assert cfValues['CustomLabelsField'].getValue() == "hello"
// output
[scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: DMI-1, actionId: 4, file: C:\Program Files\Atlassian\Application Data\JIRA\scripts\custom_label.groovy
groovy.lang.MissingPropertyException: No such property: cfValues for class: custom_label
at custom_label.run(custom_label.groovy:18)I guess my questions are:
1) what approach should I be taking to access label-type custom fields mid-transition with a custom validator script (i.e. filesystem-based)?
2) in what contexts is cfValues available and not available?
Your advice would be most welcome!
JIRA: 6.3.8 Groovy Runner: 3.0.9 Debugging: IntelliJ IDEA 14.0.1 Java: 1.7.0_75 Groovy: 2.3.7