Need JQL Script to query Stories and get back subtasks

Blaine Shirk July 7, 2020

I'm trying to write a JQL script that can return me all Stories with a specific Status AND return me ALL the associated Sub-Tasks linked to that story. 

The ideal behavior is that I could run this query and it would return to me all the Stories that have a status of (let's say "In Progress") and would also allow me to click on the Story in the Sprint Board and see all the associated sub-tasks (regardless of their status)

2 answers

1 accepted

1 vote
Answer accepted
Jack Nolddor _Sweet Bananas_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 8, 2020

Hi Blaine,

Sadly you cannot achieve the desired search using standard features on Jira, you must go for a third-party app instead. Using i.e. JQL Booster Pack if you are on Server / DataCenter, you can type the following:

 

1) Search all Stories with a specific Status (i.e. Open)

project = MyProject AND type = Story AND status = Open

2) Search for subtasks of "all Stories with a specific Status (i.e. Open)"

issue IN subtasksOf(' project = MyProject AND type = Story AND status = Open ')

3) All together <3

( project = MyProject AND type = Story AND status = Open ) OR ( issue IN subtasksOf(' project = MyProject AND type = Story AND status = Open ')  )

(*) Note that this is just an example, you must tune above query to fit your needs.

 

Using this app you can also query other issues relations, check:

 

References:

3 votes
mfabris
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.
July 8, 2020

Hi Blaine!

 

1. Make a filter with the jql

issuetype = Story AND Status = "in progress". 

Save it and it will get an id and become for example "filter 12345"

2. Make a new jql 

issueFunction in subtasksOf("filter=12345")

(You need scriptrunner for using this JQL, hopefully you have it).

 

now you want both stories AND subtasks so you will have to concatenate the two filters

 

issueFunction in subtasksOf("filter=12345") OR  (issuetype = Story AND Status = "in progress")

 

But this is not enough, if you want to use it in a sprint board; you will have issues seeing the tickets because of the complexity of the filter.

An old trick is to put another piece in front of the JQL, making sure you're restricting the filter to only the project to which your scrum users have access

 

((Project = XYZ) AND (issueFunction in subtasksOf("filter=12345") OR  (issuetype = Story AND Status = "in progress")))

 

That should do the job ;)

dbelouso February 25, 2023

This is exactly what I was looking for for days! Thank you!

Like mfabris likes this
Karen Thomas March 8, 2024

This was very helpful... good step-by-step. Thank you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events