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

Peter Bengov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 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

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

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.

Marten Kreienbrock
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

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

Thanks for the quick reply. Love the plugin :)

Marten Kreienbrock
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

Sorry, I somewhat misread your code.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

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

0 votes
Marten Kreienbrock
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 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