(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 vote

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 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
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

244 views 1 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