Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,858
Community Members
 
Community Events
165
Community Groups

Scripted Validator

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 Leader Apr 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.

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 Leader Apr 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'

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

Like Craig Nodwell likes this
Craig Nodwell Community Leader Apr 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.

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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you