Forums

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

Issue comparing collections from a customfield - Groovy

Steven Mustari
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 13, 2020
// Get the values of the Product field
def cf_product = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product")
def product = issue.getCustomFieldValue(cf_product) as List

//Products teams are responsible for
def droptableProducts = ["Image Scaling / Cleanup", "OCR", "Extraction", "Recognition", "Annotation", "Text Classification", "Purge", "Solarity Services - Legacy (Java)", "Group Separation", "Model Builder", "Validation (TP)"]

...Any usual list comparison is failing at this point...

Is there something special I'm missing about pulling in list data from a multiselect customfield?

I've tried intersect, disjoint, and iterating with .any and .every and all methods seems to be returning unexpected results.

Case:

The value "Annotation" and "Text Classification" are in the product field.

def commonValue = product.intersect(droptableProducts)

If I return product I get "[Annotation]" as expected.
If I return droptableProducts I get the list as expected.
If I return commonValue, I get an empty list.

Different method:

def found = product.any { droptableProducts.contains(it) }
return found

This always returns false no matter what values are in 'Product'.


Help! :D

0 answers

Suggest an answer

Log in or Sign up to answer