Forums

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

Trying to case search a list (from a checkbox field) to produce text string

Cody Church June 29, 2015

Hey all,

 

I previously asked this question: https://answers.atlassian.com/questions/16392854/answers/16394940/comments/16395303

But I'm still having trouble with the formatting to make this work.  Basically, I have a checkbox field that can contain multiple values, and I need to check it for specific values, then output a specific result should it contain the right values.

I believe checkbox fields make Lists, so I've set this up to search the test field 'Example'"

def List x = getCustomFieldValue("Example")
switch (x) {
 case ["Test", 'inList']:
     return "A"
       
    default:
        return "C"      
}

 

I'm stuck in the 'case' part of the search.  No matter how long the list is, I need a case function that will search through the list for "Test", and if it finds a match, will output "A".  Just can't seem to make it work.

 

1 answer

0 votes
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.
October 28, 2015

Hi Cody,

The following example works for me.

def multiSelectFieldValues = getCustomFieldValue("multiSelectExample")*.value
log.debug("Values of multi select : ${multiSelectFieldValues}")
if (multiSelectFieldValues?.contains("Option2"))
return 'Option2 is selected'

return 'Option2 is not selected'

Hope this will help you 

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events