How can i compare a cascading select field in a groovy script?

I have a cascading select field (Company / Location). Now I want to run a certain function based on a special Company but the condition does not evaulate to true.

cfValues['Firma / Ort'].contains(10617,10600)

Any Ideas?

Br.

Volker

3 answers

1 accepted

Finally, I found a solution. I had to access the first part and cast to a string.

Volker

field = (String)cfValues['Firma / Ort'].get(null)

return field=='company name as string'

2 votes

Are those the option IDs or the values? If they are option IDs you want:

cfValues['Firma / Ort']*.optionId.containsAll([10617,10600])

Hi,

I get an exception, when I try to use the optionId. javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: optionId for class: java.util.HashMap$Entry

In JQL this works: "Firma / Ort" in cascadeOption(10617, 10636)

Thanks

Volker

JIRA Version 6.1.7. Sorry, it is a cascading select field. Was to late yesterday evening.

What version of jira? Is it really a multiselect, or actually a cascading select?

Great, that works. Additionally Question: what about the JQL Term

"Firma / Ort" in cascadeOption(10617)

Same cascading select field but only the first part is important?

cfValues['CFF Name'].values()*.optionId == [10617,10600]

0 vote
def vals = cfValues['CascadingSelect'].values()
vals || vals.first().optionId == 10020

That expression is always true. If i change || to && I get an exception.

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.util.HashMap$Values.first() is applicable for argument types: () values: []

Hi, any further comments to this Problem ? This does not work...

def vals = cfValues['CascadingSelect'].values()
vals || vals.first().optionId == 10020
Best regards
Volker

yeah should have been &&

what's the exception?

Hi, as stated above: the exception is

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.util.HashMap$Values.first() is applicable for argument types: () values: [] Possible solutions: print(java.io.PrintWriter), print(java.lang.Object), sort(), find(), find(), find(groovy.lang.Closure)

I looks like the ".first()" is not available.

Br
Volker

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 Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

75 views 0 5
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