I currently have a workflow in design, which requires some fields and responses on the field selection to happen.
Here is the workflow selection as it is currently at:
DEMO required: (drop down menu)
Option 1: Yes
Option 2: No
I already have a Condition to the DEMO field:
The field Demo will have to be not equal to value 'None'. Compared as String.
I require two Simple Scripted Validators to check on each of the values.
IF Option 1 (Yes) is selected, then another field is mandatory to be filled in;
In this case A User Picker (Only certain users has been marked as usable)
cfValues['Demo'] == 'Yes' AND cfValues['Demo Attended by'] == 'NULL'
THEN Error Message: Please select user from the list
IF Option 2 (No) is selected, then another field is mandatory to be filled in;
In this case the required field is a Drop Down menu which can't be NONE which is the default value
cfValues['Demo'] == 'No' AND cfValues['Reason for No Demo'] == 'None'
THEN Error message: "Please select a reason for this request from the drop down menu"
Now my question is, will the above work. This is from a copy of a current Production Workflow which has been requested to be updated, so I don't have a test environment to see whether the above scripts will work as requested. Something else I've noticed is the following
Error message that will be provided to the user if the condition is not true
I need an error message for when the value I have given is true
The above scripts must validate that if the one option is selected another must be true for it to continue. For me they look right, but I need some more eyes on the transition to help me out.
If the field is a select field it will not work. You have to use cfValues['Demo'].getValue() to get the String value of the selected option.
If you surround your condition C with a !(C) you get the error message if C is true.
You should really get a test system (even a test project in the live system is better than nothing). Trying scripts on the production system could be really dangerous, because on wrong statement could crash the system or slow it down to an unusable state.
Thanks for your response. I'm new to the "code" side of the workflow, so please excuse my next question.
From what you have said above, I gather the following changes needs to be applied to the scripted validator:
cfValues['Demo'].getValue() == 'Yes' AND cfValues['Demo Attended by'] == 'NULL'
cfValues['Demo'].getValue() == 'No' AND cfValues['Reason for No Demo'].getValue() == 'None'
Regarding your comment about condition (C):
THEN Error message:
!(Please select a reason for this request from the drop down menu)
or should it be placed around the code above:
!(cfValues['Demo'].getValue() == 'Yes' AND cfValues['Demo Attended by'] == 'NULL')
The !() must be place around the code. It stands for NOT().
You cannot use "AND" in Groovy, it's &&.
"None" is not a real value, it's no value (null). Null is false in Groovy truth (see here).
So the validators should be
!(cfValues['Demo'].getValue() == 'Yes' && !cfValues['Demo Attended by'])
!(cfValues['Demo'].getValue() == 'No' && !cfValues['Reason for No Demo'])
Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG