JQL to show all issues AND subtasks in the Epic

Shawn Wallack June 13, 2017

I use JQL Tricks to return all issues that have a certain link type. That query is:

issue in parent("issue in linkedAllIssues(CH-58,\"contains the scope\")") OR issue in linkedAllIssues(CH-58, "contains the scope") OR issuekey = CH-58

This returns the issues that have a link type "contains the scope" with CH-58 (CH stands for "charter" by the way).

Unfortunately, it does not get deeper than the epic. So, for example, if it returns epic SF-99, SF-100, and SF-101, it does not return the issues and subtasks belonging to those epics.

Basically, in addition to what is already being returned by the JQL above, I need the JQL to also return any issue and subtasks whose epic link “is scope within” the selected charter.

3 answers

2 votes
Junio Fernandes November 29, 2017

In my case I use AM Utils (free add-on) to search all issues and subtasks on it:

A simple example:

issuekey in (issuesSubtasks("'Epic Link' = XXX-99")) ORDER BY Rank ASC

With this I can make boards that swinlanes with stories or projects besides the Epic Link. 

0 votes
Anna Kubaty October 27, 2021

I use:

parentEpic = AB-12345

or:

parentEpic in (AB-12345, AB-67890)

0 votes
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2017

You need something like ScriptRunner or JQL Tricks to do nested JQL queries. I have not used ScriptRunner's JQL function for it (we have both plugins), but we are using JQL Tricks to search for all issues and sub tasks that are linked to specific epics.

Shawn Wallack August 9, 2017

Thanks. But... can you share the JQL?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2017

Here is a query we use to get all issues linked to a specific epic:

project = X AND issue in issuesWhereEpicIn("project = X AND issuekey = X-XXX")

In your case your query should look something like this (I have not tested it so you may have to tweak it a bit):

issuesWhereEpicIn ("issue in parent("issue in linkedAllIssues(CH-58,\"contains the scope\")") OR issue in linkedAllIssues(CH-58, "contains the scope") OR issuekey = CH-58")

Shawn Wallack August 10, 2017

Thank you. I sincerely appreciate the help. When I enter that query into the search box, however, I get an error: 

Error in the JQL Query: Expecting operator but got '('. The valid operators are '=', '!=', '<', '>', '<=', '>=', '~', '!~', 'IN', 'NOT IN', 'IS' and 'IS NOT'. (line 1, character 19)

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2017

Okay, so I played around a bit in my test environment and this query works there:

issue in issuesWhereEpicIn("issue in linkedAllIssues(CH-58, \"contains the scope\")") OR issue in parent("issue in linkedAllIssues(CH-58,\"contains the scope\")") OR issue in linkedAllIssues(CH-58, "contains the scope") OR issuekey = CH-58

Jeffrey Freund October 9, 2018

We have Scriptrunner installed.  Can someone suggest the JQL that would work similar to what was done using the JQL Tricks plugin?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 9, 2018

@Jeffrey Freund You would have to create a filter that selects all the stories/tasks first that is linked to the epic, something like this:

issueFunction in issuesInEpics("issuekey = JRA-1")

Save that as  a filter and then you can search for subtasks linked to any of the stories/tasks found by the filter using this query:

issuefunction in subtasksOf("filter = 'Stories in Epic'")

See More Complex Examples for more information.

Side note; Next time, please create your own question and reference the original one, makes it a bit cleaner.

Samambaia February 1, 2021

Nice. Works for me! Thanx a lot

Like Mikael Sandberg likes this

Suggest an answer

Log in or Sign up to answer