(Script Runner) Custom field value equals to one of the given options

Peter Bengov Community Champion Jul 29, 2014

Hi all,

I have a custom field from type Select List.

I would like to make a different custom field required when this select list field's value is equal one of 3 options (the select list contains 7 options total).

I'm trying to set this rule via Workflow validator with the use of Script Runner. If I would have liked to be based on just one of the values in the select list, I could have used this with no problem:

cfValues['selectListCF']*.value.contains('ticketCanBeCreated') || cfValues['selectListCF']*.value.contains('oneOfTheOptionsThatRequiresMandatoryValueInOtherCF') && cfValues['cfIWantToMakeMandatory']!=null

Is there an option to choose more than one value of a select list using Script Runner?

Thanks guys

2 answers

1 accepted

This widget could not be displayed.

You could do as Marten said but easier would be:

['ticketCanBeCreated', 'oneOfTheOptionsThatRequiresMandatoryValueInOtherCF'].contains(cfValues['selectListCF'].value)

Don't know use *.value unless it's a multiselect.

But wouldn't this enable tickets for any of the selectList values? He just wanted it enabled for 3 out of the 7 possible values

Peter Bengov Community Champion Jul 29, 2014

Jamie, you solution worked like a charm. Exactly what I was looking for.

Thanks for the quick reply. Love the plugin :)

Sorry, I somewhat misread your code.

I don't really understand the question. The way I read it oneOfTheOptionsThatRequiresMandatoryValueInOtherCF was one of the options.

This widget could not be displayed.

Without knowing to much about Script Runner, I would recommend an easy work-around by creating two workflow validators (one for each value). You should be able to link them together with the help of jiras workflow editor to create a similar "OR" logic.

Peter Bengov Community Champion Jul 29, 2014

Thanks for the answer, Marten. The creation of more workflow steps did was something I considered, but since it might end-up with doing a lot of maintenance work I wanted to make sure all other options are covered. Have a good day

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

169 views 1 3
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