Forums

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

JQL query User story and defects

Garden16_ December 20, 2023

Need a JQL query for the user story and the  defects associated with the User story using Script runner  JQL functions.

 

We have defects linked to User story. We would like to see all defects related to the user story. We need a report that displays all the user stories and its associated defects and total count of defects related to the user story 

User story and defects.PNG  

2 answers

1 vote
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2023

Hello @Garden16_ 

What version of Jira are you using and what version of ScriptRunner are you using?

You should be able to use the linkedIssuesOf ScriptRunner function to get the Bugs linked to Stories.

First you construct the query that will get the stories you want; i.e.

project=x and issueType=Story

Add to that the linkedIssuesOf function to get issues linked to those stories.

project=X and issueType=Story or 

issueFunction in linkedIssuesOf("project=X and issueType=Story") 

Add criteria to limit the linked issues to only Bugs:

project=X and issueType=Story or 

(issueFunction in linkedIssuesOf("project=X and issueType=Story") and issueType=Bug)

That will give you a list of the issue, but not in the format you showed. Jira does not natively have the capability to produce a report in that format.

 

You could use a ScriptRunner Scripted Field to keep track of the Bug issues linked to your Story.

https://docs.adaptavist.com/sr4js/latest/features/script-fields

Garden16_ December 20, 2023

We have script runner Version:

6.56.0 Data center 
and JIRA  8.0.1
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2023

All of my references to ScriptRunner documentation were to the latest version - 8.18.0. You would need to double check the documentation for the version you are actually using to confirm that the same functionality is available and used in the same manner.

Garden16_ December 21, 2023
(issueFunction in linkedIssuesOf("project=X and issueType=Story") and issueType=Bug)

when I run this query  its shows the list of defects that linked to all issue types

its showing defects, tests, test execution issue types which are all linked to the defect.

 

If I flip the query it shows the story and every thing that is linked to the story

(issueFunction in linkedIssuesOf("project=X and issueType=Bug") and issueType=Story )

 

How will I create query that shows 'only issue type =bugs ' linked to the user story.

Please advise how to  display only defect issue types linked to the user story User story and defects.PNG

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2023

According to the documentation for ScriptRunner 6.56.0

https://docs.adaptavist.com/sr4js/6.56.0/features/jql-functions/included-jql-functions/issue-links#linkedissuesof

...it should work the way I provided it.

Can you provide a screen image that shows the query actually being executed and the results, plus the details of one of the defects that is linked to an issue type other than Story?

Garden16_ December 22, 2023 edited

Story and defects.PNG

Garden16_ December 22, 2023

In this scenario 90 is Test , 177 and 148 are defects

I wanted to display only defects that are linked to the User story . How do I achieve this.

 

I want to put in the Dashboard user story and their associated (linked) defects .

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 22, 2023

The Linked Issues field you included in the columns will show all the linked issues of the listed issue. There is no method to change what is displayed in that field.

You asked for a list of defects that are linked to Stories. The first query I provided produces a list that includes each Story and each defect that is linked to one of the stories. Each Story and defect will be a separate item in the list.

If what you want is something like you've shown, then with ScriptRunner I think you would have to create another scripted field where you could insert a list of the issue keys for just the defects linked to a Story.

0 votes
Hannes Obweger - JXL for Jira
Atlassian Partner
December 20, 2023

Hi @Garden16_

if you're open to solutions from the Atlassian Marketplace, this may want to have a look at the app that my team and I are working on, JXL for Jira.

JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you’d do in e.g. Excel or Google Sheets. It also comes with a number of so-called smart columns that aren’t natively available, the number of linked issues, and many other issue-link-related columns. With these, you should be able to build the view you're looking for in just a couple of clicks:

linked-qa-defects.gif

JXL also comes with a number of advanced features, including support for (configurable) issue hierarchies, issue grouping by any issue field(s), sum-ups, or conditional formatting - depending on your exact use case, I believe that these could be useful as well.

Note that this all just works, and doesn't require any scripting or automation whatsoever.

Any questions just let me know,

Best,

Hannes

Garden16_ December 20, 2023 edited

We do have JXL also . Can you suggest how to create this report and put it in the JIRA dashboardUser story and defects.PNG

Suggest an answer

Log in or Sign up to answer