restrict Priority values on edit - revisited

A) This works (restrict priorities to those with ID less than 5)

def allowedPriorities = constantsManager.getPriorityObjects().findAll{
	it.id.toInteger() < 5
}.collectEntries {
	[(it.id): it.name]
}
priority.setFieldOptions(allowedPriorities)

 

B) This does NOT work (attempting to restrict priorities to only 1 & 3)

def allowedPriorities = constantsManager.getPriorityObjects().findAll{
	it.id.toInteger() == [1,3]
}.collectEntries {
	[(it.id): it.name]
}
priority.setFieldOptions(allowedPriorities)

 

Can someone please help me with why code snippet B does not work?

Thanks in advance,

Conor

 

 

1 answer

1 accepted

Hi Conor, 

If you want to get only priorities with ids 1 or 3 then the findAll closure should be

it.id.toInteger() in [1, 3]

That simple smile

Thanks Thanos!

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
Posted 3 hours ago in Off-topic

Miscellaneous Monday - CreatatronV3

You may remember, not so long ago, that together we invented the most evil of machines: The Destructo5000!  The effects of missing Durian rippled over nations. Complete chaos as goat chee...

38 views 3 2
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