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

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++){
   if(oSelect.options[i].selected){
       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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Posted 13 hours ago in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

36 views 0 5
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