I have a script in a scriptrunner validator to validate a value is populated when another value is selected. Here is the script:
issue.customfield_10177?.value == "Remote Location" ? issue.customfield_10178 != null : true
10177 is a check box
10178 is a text field
When I select that value and leave the text field blank, it is not giving a validation error. Is this because of the field type?
Hi Todd,
I can confirm we have an example validator located here on line 59, which shows how you can validate that a checkbox field has one specific value selected and that a single line text field is not null.
You can take this validator and use it to help create the validator you need to solve your requirement.
I hope this answer helps.
Regards,
Kristian
Is the length of the checkbox field important?
I updated the script to
issue.customfield_10177[0].value == "Remote Location" && issue.customfield_10178 != null : true
and am now getting an error on all attempts to use this validator:
The following validator rejected the transition: ScriptRunner Script. The configuration is invalid. Contact the app vendor that provided this workflow element.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Todd,
This error means the Expression failed, as your syntax for the Jira Expression Framework provided by Atlassian which we use is invalid.
Specifying the length of the checkbox makes the syntax correct and means that this is the only value selected.
If you want any of the values in the field to match then I have added a new example here on line 64 that you can use to achieve this.
I hope this helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.