Forums

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

JMWE Validation for checking Single select List option

Julian Governale
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2019

Im trying to write a validation where is checks to see if the option "Other" is selected in the single selection list called test type list (cf_10619).  if option "other" is selected then test Type "Other" (cf_10620) is required, otherwise it is not required. 

So far i have tried the below - but this just returns a boolean that something has been selected from the the test type list (cf_10619) and that test type other (cf_10620) is not empty.

No matter which selection is made, this always requires Test Type "other" to be required

issue.customfield_10619.value == "Other" && !! issue.customfield_10620

 using JWME and unfortunately im not a developer so im sure this is the basics of JS development that i do not know. 

Any help would be greatly appreciated. 

1 answer

1 accepted

0 votes
Answer accepted
Julian Governale
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2019

After playing with this for a little i was able to get this to work by using the below code.  if anyone knows are more elegent way to do this, please let me know.

Code that worked:

issue.customfield_10619.value != "Other" || ( issue.customfield_10619.value == "Other" && !! issue.customfield_10620 )
David Fischer
Community Champion
October 4, 2019

Hi Julian,

you can actually simplify your expression this way:

issue.customfield_10619.value != "Other" || !! issue.customfield_10620

because if the first part of the expression is false, it means that issue.customfield_10619.value == "Other" so you don't have to test it again.

Like Jhonattan Lima Campos likes this
Julian Governale
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2019

Thanks David, that simplified it a lot actually.  Thanks for the explanation as well!

Suggest an answer

Log in or Sign up to answer