restrict Priority values on edit - revisited

Conor McGmail November 24, 2016

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

0 votes
Answer accepted
Thanos Batagiannis _Adaptavist_
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.
November 24, 2016

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]
Conor McGmail November 24, 2016

That simple smile

Thanks Thanos!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events