Forums

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

How can I write a JQL query to select all stories, tasks and "sub-tasks" under an Epic

adavies March 4, 2021

"How can I write a JQL query to select all stories and tasks that have a given epic link as well as all sub-tasks of tasks or stories that have a given epic link?"

The first part is easy ...

project = INFRA AND "Epic Link" = Databases ORDER BY Rank ASC

... it's the second part that is the real puzzler.

Let me start by saying that I've spent quite while Googling on this question already and all the supposed solutions that I've seen require the use of addons.  I want to find a solution to the above that DOES NOT require an addon.  I think it's a perfectly reasonable to want to create a view (board or whatever) that includes all the items that are hierarchically structured under a given higher level object in the Jira object model.  I sincerely hope that this is possible given the base-level capabilities of JQL.

How can I do this?

4 answers

1 accepted

1 vote
Answer accepted
adavies March 4, 2021

Aha!  parentEpic wants the epic key not the epic name!!!  That's intuitive.  So this works ...

parentEpic = INFRA-5

So this actually does what I want ...

project = INFRA AND ("Epic Link" = Databases OR parentEpic = INFRA-5) ORDER BY Rank ASC

Or more specifically this ...

project = INFRA AND ("Epic Link" = Databases OR (parentEpic = INFRA-5 AND key != INFRA-5)) ORDER BY Rank ASC

... since the first query returns the epic itself.  The second query returns just the stories, tasks and sub-tasks.


adavies March 4, 2021

Actually, the "Epic Link" condition is now redundant.  These two queries return the same issues ...

project = INFRA AND ("Epic Link" = Databases OR (parentEpic = INFRA-5 AND key != INFRA-5)) ORDER BY Rank ASC

project = INFRA AND parentEpic = INFRA-5 AND key != INFRA-5 ORDER BY Rank ASC

adavies March 4, 2021

INFRA-5 is the key for the epic called Databases

0 votes
John Funk
Community Champion
March 4, 2021

Hi @adavies  - Welcome to the Atlassian Community!

You will need an add-on such as ScriptRunner to be able to get the sub-tasks. See this link for some more information:

https://community.atlassian.com/t5/Jira-Software-questions/JQL-Query-Sub-Tasks-Parent-Epic-or-User-Story/qaq-p/1582188

adavies March 4, 2021

I refer the honorable gentleman to this quote from my original question ...

"I want to find a solution to the above that DOES NOT require an addon"

John Funk
Community Champion
March 4, 2021

Duly noted - but I don't believe you will find a solution otherwise.  :-)

adavies March 4, 2021

Oh contraire Blackadder ...

John Funk
Community Champion
March 4, 2021

:-)

0 votes
adavies March 4, 2021

...

0 votes
adavies March 4, 2021

To add more context, I am using the Jira cloud product

adavies March 4, 2021

I have found references to a JQL function called "parentEpic" ...

https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-functions/

The examples on that page seem to suggest that this would work ...

Find issues and sub-tasks in the epic DEMO-123:

parentEpic = Databases

but when I use that in my Jira instance I get this error ...

"The issue key 'Databases' for field 'parentEpic' is invalid."

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events