It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Validate multi select customfield in transition

I would like to validate the selected option(s) of a multi select customfield in order to check if an other field is filled or not.

I already do this for select lists using a simple scripted validator (groovy script runner plugin):

if ( cfValues['some select list'].value == "some value") {
  if ( !cfValues['some dependent customfield'] ) {false} else {true}
} else {true}

How does the script have to look like when using a multi select list instead of a select list?

2 answers

1 accepted

You want to see if your multiselect contains some option value? It should return a List of Options, so you could use:

cfValues["Some Multiselect"]*.value.contains("Some value")

Note spread-dot operator to convert list of Options to list of Strings.

Note that if you had tagged your question you might get better answers.

You need to add a null check too as you will get null when there are no options set.

Thank you very much. That works :-)

Jamie, it seems that -- more often than not -- whenever I have a pressing question, your proposed solutions are the ones that save me (even when I'm not the one posting the question).

Thanks again and again and again.

Have a great weekend.

Hi Wolf,

You need to add a "For" condition before the if else condition, since it is multi select, you need to take the options and you need to check whether the option is selected. Then you can have your logic. For eg

for(var i=0;i<oSelect.options.length;i++){
       Have your logic

Sorry to downvote but you have written javascript, whereas he is using groovy.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 09, 2019 in Portfolio for Jira

Portfolio for Jira 3.0 is here!

The wait is over... Portfolio for Jira Server and Data Center 3.0 is now officially here! Platform releases offer Atlassian an opportunity to shift our strategy, make bold predictions about t...

1,673 views 14 26
Read article

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you