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

This widget could not be displayed.

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.

This widget could not be displayed.

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 Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

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