Forums

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

Search for issues with more than 1 value in a multi select field?

Cindi Cunningham
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 8, 2021

I saw this question posted earlier but the suggested answer doesn't actually answer the question. That answer seemed to explain how to find a specific value.

I am, however, wanting to write a script to show issues that have more than one value selected in a multi-select field. 

Use case: we have a Program Increment field on epics. This field is multi-select so we can report on epics that take more than one PI to complete. I want to run a script to show me epics where more than one option is selected in the Program Increment multi-select field. 

2 answers

0 votes
CJ Edwards
Contributor
April 8, 2021

Hi Cindi

If you are going to groovy it, as Martin suggested, start with a JQL query to narrow results and then you can cycle through a find the ones that have more than one entry and "do"  something you would like.
This would need tweaking to your tastes

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sourceField = customFieldManager.getCustomFieldObject('customfield_10000') /need your actual # for Program Increment
def
 jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def query = jqlQueryParser.parseQuery("project = myproject AND issuetype = Epic and 'Program Increment' is not EMPTY")
def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
def issues = search.getResults()

issues.each{ issue ->

if (issue.getCustomFieldValue(sourceField).size()>1) {
do something! (spit out a list etc...)
}
}

Hope this helps as well.

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
April 8, 2021

Hi @Cindi Cunningham , welcome on the community. I'm not aware of possibility to achieve this using JQL by default.

If you just want to run a groovy script, I think the most effective approach is to

  • search for issues in required project with issue type Epic and Program Increment has at least one value, something like
    • project = myproject AND issuetype = Epic and 'Program Increment' is not EMPTY
  • then load value of Program Increment custom field
  • then filter issues which has more than 1 value in Program Increment custom field
Cindi Cunningham
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 8, 2021

Thank-you. I will try that!

Suggest an answer

Log in or Sign up to answer