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

Accepted Answer
2 votes

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
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

82 views 0 4
Join discussion

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