Groovy Script compare version picker

Hi all,

I want to compare two version picker fields with a groovyscript. each version picker fields can have

multiple versions. the validator should check if version(s) entered in picker a are also entered in picker b. so e.g. I have a field for wich version help needs to be updated and this version must be in the field for the already fixed version(s).

How can I do that?

3 answers

1 accepted

0 vote
cfValues["Picker A"].containsAll(cfValues["Picker B"])

will be true if the values in A are a superset of those in B. That's for a "simple scripted condition", for a longhand script get the custom field values and use containsAll as above.

note: will throw exception if called on an issue that does not have both these CFs associated with it.

Hi Jamie,

thanks for your answer. When I enter your mentioned code into the condition tester I get this error:

javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method containsAll() on null object

the two pickers contain the same version

Can you paste a screenshot of how this is configured. Also check the names of the two fields, they must be typed exactly as they are displayed in the screen.

Sorry my fault. Now it works like a charm.

hi - I have the same issue, except that I want to compare the custom field with the built in field "Fix Version\s".  Is the syntax the same?  Or is there a different way to get values from built-in fields? 

cfValues["Resolved Version"].containsAll(cfValues["FixVersion"])

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
Posted yesterday in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

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