Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted Validator

Sravan Duddella
Contributor
April 29, 2022

Hello Team,
Can you please help me with this validator?
We have a field "XYZ" with Yes/No/Unknown options, default value set to Unknown and to push the workflow status to In-progress we need this field's options be either Yes or No. Can you please help ASAP? Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Craig Nodwell
Community Champion
April 29, 2022

Hi @Sravan Duddella from the Scriptrunner page
cfValues['My Multi Select']*.value.contains("Some value")

Scriptrunner validators simple-scripted-validators-multi-select 

Here's a more complex example from the Scriptrunner Library
Scriptrunner Library Scripted Validator Multi-Select List 

 

I hope this helps to get you started.
Happy Scripting.

Sravan Duddella
Contributor
April 29, 2022

Hello Craig, Thanks for posting this, so the field is single select but the value can be either Yes or No.

 

using the below argument is throwing errors, looking forward for some help on the right argument to use.  

cfValues['xyz']?.value == "Yes or No"

Craig Nodwell
Community Champion
April 29, 2022

Instead of testing for Yes or No why not test what it is not equal to.
re:
cfValues['xyz']?.value != "Unknown"

or to test for the OR
cfValues['Demo']?.value == 'Yes' || cfValues['Demo']?.value == 'No'

Sravan Duddella
Contributor
April 29, 2022

AWESOME! Worked like a charm!!! Thank you so much!!!

Like • Craig Nodwell likes this
Craig Nodwell
Community Champion
April 29, 2022

Old guy tip.

I hope you used the != to simplify complexity.
Reasoning here is the only value that is invalid is "Unknown" all other values are valid, so therefore you only need to test that the value is not equal to "Unknown".
Testing for the OR requires the system to evaluate the value twice, adding unnecessary complexity to the scripted validator which may be difficult for someone new reading it later on down the line.

Sravan Duddella
Contributor
April 29, 2022

Understood!! Makes complete sense and a lot much easy to implement and read. :)

Like • Craig Nodwell likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events