
I am attempting to use the JIRA Behaviours Plugin and could use assistance.
Problem Statement:
I am attempting to write a script that will compare the values of custom number fields. Each month I must gather inputs from managers on what project their headcount is working on. I need to validate their entries against what is rolled up by the Finance dept. I created a ticket on the Atlassian Support page and received a reply from Jaime Echlin with the following script:
FormField f = getFieldByName("U.S. Headcount")
def is8 = f.getValue() == 8
if (is8) {
f.clearError()
}
else {
f.setError("You must enter 8")
}
The problems with this code was the following:
1) The error message appears before an entry is even made. Ideally I would prefer the error to appear if the entry is wrong.
2) Once the correct entry is entered nothing occurs. Correct entry should allow user to create issue and or proceed through a workflow
3) Ideally instead of having to hard code the value to validate I would prefer for a check to be issued against the comparison field. Example Psuedocode:
Manager Field ID should equal Finance Field ID
If manager field ID value does not equal finance field ID value
stop issue from being created and/or proceeding through workflow and throw error message
If manager field ID value does equal Finance Field ID value
allow issue to be created and/or process through workflow
4) There a total of 6-8 manager fields that need to be compared to 6-8 finance fields.
In attempting to write this script have pursued the Sample.Groovy file in the plug-in itself to know avail. Any assistand would be highly appreciated. Thanks.
*Atlassian documenatation states to review the Sample.Groovy file to see how certain examples are created. I did not locate a Sample.Groovy file. Did find a ScriptSample.Groovy file? Is that where the examples are?