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

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

1 votes

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

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.

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.

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,076 views 13 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot