Groovy Script Listener -- conditional with multiselect custom field?

Hi,

I am using Script Listener version 1.7.13 on Jira 4.1.1

I have a script listener that looks for issues with a custom field like so:

cfValues['Severity'] == '1'

-- this condition works great. The customfield type is select/selectsearcher

However, when I try to look for something that is in a multiselect/multiselectsearcher field, it is returning as false. Example:

cfValues['External Customer'] == 'Test User'

This also returns as false:

cfValues['External Customer'].value == 'Test User'

This also returns as false:

cfValues['customfield_11006'] == 'Test User'

....

Based on some posts I found online, I checked to see if customfield was being represented as an array, and that it contained 'Test User' So I modified my condition like so:

cfValues["External Customer"] && cfValues["External Customer"]?.value.contains("Test User")

Still returning false.

At this point I am stumped...

Any tips appreciated!

2 answers

1 accepted

I modified my query a bit, and now it works:

cfValues["External Customer"]?.contains("Test User")

This is the correct answer... if the custom field type is a List, you need to use contains, unless you are testing for list equality. But the key point is to:

log.warn cfValues["External Customer"].class

Then you can see the type that you are getting.


Hi Bryan,

That's because you need to declare the customfield first, you could try:

def cf = "customfield_11006"

def fieldname = customFieldManager.getCustomFieldObject( cf )

cfValues['fieldname'] == 'Test User'

Something like this.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

688 views 6 13
Read article

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