Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Volker Wend April 2, 2014

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

0 votes
Answer accepted
Volker Wend April 12, 2014

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
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.
April 2, 2014

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

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

Volker Wend April 2, 2014

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

Volker Wend April 2, 2014

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

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.
April 2, 2014

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

Volker Wend April 2, 2014

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?

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.
April 2, 2014

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

0 votes
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.
April 2, 2014
def vals = cfValues['CascadingSelect'].values()
vals || vals.first().optionId == 10020

Volker Wend April 2, 2014

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: []

Volker Wend April 8, 2014

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

def vals = cfValues['CascadingSelect'].values()
vals || vals.first().optionId == 10020
Best regards
Volker
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.
April 8, 2014

yeah should have been &&

what's the exception?

Volker Wend April 9, 2014

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
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events