JQL to show all issues AND subtasks in the Epic

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.

2 answers

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
Mikael Sandberg Community Champion Aug 09, 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.

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

Mikael Sandberg Community Champion Aug 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")

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 Champion Aug 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

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 Champion Oct 09, 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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

107 views 4 8
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you