// Get the values of the Product field
def cf_product = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product")
def product = cf_product.getValue(issue) 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 failing. And by failing I mean returning unexpected results.
Case:
The value "Annotation" is 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.
Help! :D
Hi Steven,
I'm going to try and point your nose in the (what I think) right direction.
You have 2 List you are trying to compare: dropTableProducts and products. In order to sucessfully compare the items in Lists, the contents need to be of the same type or need to be comparable to each other.
Although this might seem to be the case because the product List seems to contains the value "Annotation" in your example, it does not. What you see when you print out the value of that List is the String representation of that "Annotation" option. The actual type of List product is => class com.atlassian.jira.issue.customfields.option.LazyLoadedOption
You can validate this by doing this:
// Get the values of the Product field
def cf_product = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Product")
def product = cf_product.getValue(issue) as List
return product.get(0).getClass()
This will return the type of the data in your first element of the product List.
Your second List (dropTableProducts) is of type String. Comparing those 2 Lists will give very weird results, since there is no way for groovy to know how to compare en Option with a String.
Solution:
From the products customfield get the String values of the selected options and put them in a List. Then compare that List with your dropTableProducts. That should work.
Let me know if this helped or if you have any more questions!
Regards,
Jeroen
Jeroen,
Thank you for the detailed explanation. This makes sense to me now, I appreciate the assistance!
Regards,
Steven
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.