Forums

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

How to query on affectedVersion when multiple versions are listed?

Dave May 12, 2020

We track bugs from external customers in a JIRA project.  Our Technical Services team files the issues and updates them if they learn more information (especially when a specific bug affects multiple customers).

They update via comments, or add other information as well, including updating the affectedVersion field (so we know exactly which versions of the software are affected by that particular bug).

How can I query against the list of issues in the project that *only* affects one of the versions?

Example:

BUG-12345

Affects Version/s:  V1,V2,V3
BUG-23456

Affects Version/s: V3

My JQL looks like this;

project = BUG AND affectedVersion = V3 

 The query returns 2 issues - BUG-12345 and BUG-23456.  I want it to only return BUG-23456.

I know that I could add another section to the JQL that says:

AND affectedVersion not in (V1,V2)

We have many, many versions in this field and it would be impractical to list them all. 

Thank you in advance for any help you can provide.

1 answer

1 accepted

0 votes
Answer accepted
Gergely Fehér
Contributor
May 12, 2020

If you have Scriptrunner plugin, you can create a scripted field that stores the number of values in affectedVersion, and based on that you can create your jql query.

Dave May 12, 2020

What if we don't have it?

We might, I'm not sure.  I'll have to check with the JIRA admin tomorrow.

Dave May 14, 2020

We do have Scriptrunner.  I am working with our JIRA developer to come up with a query that will work.

It seems like this should "just work" out of the box.

Gergely Fehér
Contributor
May 14, 2020

with scriptrunner I use a scripted field for the number of values in sprint field for each issue, something like this could help your query too:

import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Sprint")[0]
def sprints = issue.getCustomFieldValue(cf) as List <Sprint>

sprints?.size()
Dave May 15, 2020

That does help, thank you for the suggestion!

Suggest an answer

Log in or Sign up to answer