JQL to show all issues AND subtasks in the Epic

Is there a way using JQL to query for all issues AND their corresponding sub-tasks for any given epic?

I tried using "Epic Link" = PRJ-1134 , but that only shows my stories, not my sub-tasks that are connected to those stories.

Thank you!

36 answers

2 accepted

Install the free ScriptRunner plugin and then use the following query where XX-### is your issue key:

("Epic Link"=XX-###) OR issueFunction in subtasksOf("\"Epic Link\"=XX-###")

Thanks Saikat. That works great, and without having to purchase a plugin.

Doesn't work for OnDemand...

The onDemand APi does not support JQL functions for 3rd parrty add-ons. However, Links Hierarchy for Cloud may help a lot as users can display ful Epics hierarchies graphically and export them intto the Issue Navigator!

[Edited to add picture]

Cool ... This worked...No plugin required... smart Move.!!

wicked cheers for that (we have the Adaptavist script runner plugin), also modified to include, OPEN sub tasks, issues and risks asscoiated with the perant EPIC:
(issueFunction in subtasksOf("\"Epic Link\"=XX-XX") or (issuetype in (Issue, risk) and "Epic Link" = XX-XX) and status not in (closed))

Im 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. 

Great solution!  Thanks for such an easy way to get all related issues.

Solution to show all Items in an Epic is this without having to use any plugin:

project = CC AND "Epic Link" = CC-2 OR parent in ("CC-2")

Hope this helps.

This is great!

What does the "parent in" part do?

Unfortunately this doens't list sub-tasks as they're on issue though... have you been able to achieve this?

This works only when you have scriptrunner plugin installed

Doesn't list Sub-tasks, as the original question require. Tested on Jira Software Server 7.3. This shows the issues directly linked to the Epic, not the sub-tasks under stories.

instead of parent use parentEpic = XX-##

 

This works in Cloud without any plugins. 

I'm using OnDemand so the plugins aren't available to me. I did notice that this query meant for another product is working...

"Epic Link" in (XXX-####, YYY-###, ZZZ-####) OR parent in tempoEpicIssues(XXX-####, YYY-###, ZZZ-####)

Sweet, that definitely worked for me, specifically

parent in tempoEpicIssues(XXX-####, YYY-###, ZZZ-####)

pulls in all subtasks for a specific epic.

Hi

On the similar lines, i want to get all stories for multiple epics and person working on those epics

below query is giving me error!! it is not allowing multiple values for Epic Link!!

project = TEST AND issuetype = Story AND "Epic Link" = (TEST-1275,TEST-955,TEST-966) AND "manager" = userid ORDER BY description

"manager" is in Epic, not in story.

Can somebody help with this query, Appreciate it.

thanks

I'm not 100% sure and don't have Epic to test this, but I expect changing your "Epic Link" argument from = to IN will do the trick. Try:

project = TEST AND issuetype = Story AND "Epic Link" IN (TEST-1275,TEST-955,TEST-966) AND "manager" = userid ORDER BY description

Just want to add my thanks for the work around. You're making me look very, very smart at my company.

This seems to rely on Tempo TimeTracker - I don't have this installed. Is it normally installed by default?

Currently, some few add-ons  like Tempo and others, directly run on the Atlassian's Cloud Server instances whereas the rest of the 3rd party Cloud add-ons run on their own Cloud Server instances.

These add-on exceptions will be moved out of the Atlassian's Cloud Server instances. You might want to contact to the add-on Cloud provider in order to know if a feature is long-term supported.because the Atlassian's Cloud API is very limited compared to the Atlassian's Server API and some features might be unavailable once the add-on is migrated to an external (no-Atlassian) Cloud Server. 

It looks like tempoEpicIssues is no longer supported in OnDemand.... What's the new workaround??? There has to be a supported solution by now, no?

I'm using OnDemand and the tempoEpicIssues() worked (for me) to find all sub-tasks within that epic.

14 votes
Dave Meyer Atlassian Team Jan 12, 2017

13 January 2017

Hi everyone,

As part of the migration of Tempo Timesheets to a new technology platform, the tempoEpicIssues() JQL function is either already removed or will be removed soon (depending on whether your instance has a license for Tempo Timesheets).

However, I'm pleased to announce the parentEpic function is now available in JIRA Cloud as a replacement. Searching with parentEpic will return all the issues in the specified epic(s) AND their sub-tasks. The syntax is a little bit different than a standard JQL functions – it's more like searching with a field. So

project = JRA and parentEpic = JRA-123

will return all issues and sub-tasks in the JRA project that are in the JRA-123 epic. The function also supports the != , IN , and NOT IN operators. So you could also search something like

project = JRA and parentEpic in (JRA-123, JRA-456) 

and you will get all issues and sub-tasks in either the JRA-123 or JRA-456 epics.

Refer to the documentation for more information. Happy searching!

Dave Meyer

Senior Product Manager, JIRA

warning Note: If your JIRA Cloud instance currently has a license for Tempo Timesheets, the tempoEpicIssues() JQL function should still be available. You can manually change your filters to use the parentEpic function, or wait until they are automatically updated as part of the migration to Tempo's new Cloud technology platform

This is perfect Dave - thank you!  This is a drop in replacement for tempoEpicIssues() and needs some up-voting.

I've been using the syntax on Kanban board quick filters to filter by Epic:

"Epic Link" = FOO-123 OR parent in tempoEpicIssues(FOO-123)

The parentEpic function is a direct replacement for the above.  I've just converted all my filters to just:

parentEpic = FOO-123

Thank you!

Related to this, thought you may be the guy to ask. I have kind of the opposite issue when using Agile Boards and Filters.

If I use epics as swim lanes, and use a quick filter by say, Assignee, every sub-ticket gets moved to "Issues Without epics" section, and out of the epic swimlane of its parent, because the parent does not match the filter. We totally lose all organization by epic when this happens, making the swimlane useless. We need the sub-ticket to stay in the epic swimlane of its parent. This is basic stuff we need to make JIRA boards usable. It has been described in bug reports and question pages below. Any input? 

Atlassian question:

https://answers.atlassian.com/questions/39988150


JIRA bug:
https://jira.atlassian.com/browse/JSW-10683 

 

Hi Dave,

is this new function available on Server too?

Thanks

Dave Meyer Atlassian Team Jan 30, 2017

Hi @Jan Scherks. No, not right now.

Works for me!!!  Awesome and thank you!

 

Works for me. Thanks!

When will this be available in Server?

Looks great, when do you plan to release it for server.

This worked great for me and did exactly what i needed it to do.

A bit late answer, but it might help users resding this in the future :)

The Links Hierarchy add-on can get the full hierarchy in a very simple way:

issue in linksHierarchyIssue('PRJ-1134', 0)

The JQL above will build the full hierarchy tree in memory and will collect all the issues into a flat table, including Epics and Subtasks.

A clear advantage of this add-on is that you can explore the hierarchy for each returned issue in a visual way an understand and verify the results with the fully sincrhonized interactive HTML 5 link viewer.


This JQL returns all issues in the hierarchy in random order. Is there a way to return results that preserve the hierarchial view?

Again, no one using Cloud is helped by this, and is why we need Atlassian to include the basic functionality itself.

2 votes

It is possible to do with Structure plugin, if you have it installed or don't mind trying. The solution consists of 2 parts: (a) installing synchronizer(s) that will maintain a hierarchy that reflects epic-story-subtasks hierarchy, and (b) using S-JQL to extract portions of the structure (a hierarchy under a specific issue, for example). It requires some setup to get going, but after that it should be easy to work with.

Here's a brief walkthrough to create the structure:

  1. Create a new structure "our structure" and open it (it is empty initially).
  2. Click "Search", click "JQL" small button in the search box, and enter JQL "project = PRJ and type in (Epic, Story)". Turn on "More Issues" button if it is off. Click "Add All" to add all matching issues to the structure. Now you should have all interesting epics and stories in the structure as a flat list.
  3. Use menu Structure | Manage Structure, click on the "Settings" link in the "Sync With" column, and select "GreenHopper". Proceed to entering the parameters. Select project PRJ, turn on "Force Sub-tasks", set "Epic Field" to "Scrum Board Epics", and "Rank Field" to "Don't synchronize".
  4. Proceed to "Resync and Enable" the synchronizer, choose the direction "from GreenHopper to Structure" (sic! it's important to choose the correct direction)
  5. Open structure - you'll see stories arranged under their epics, and having all their sub-tasks under them.

Now you have a structure that represents Epics, Stories and Sub-tasks. Note that moving stories from under one epic to another will also update the epic association (and vice versa), so this structure is live.

Now you're ready to query for issues that belong to certain epic. The JQL for your own example would be this:

issue in structure('our structure', 'ancestor or issue = PRJ-1134')

There are many more variants of S-JQL queries. Please see docs at https://wiki.almworks.com/x/coPE

The documentation on GreenHopper synchronizer is here: https://wiki.almworks.com/x/mwBg

Hope this helps!
Igor

Hi Igor, It works great and i am able to build dasbhboard showing Epic > Story > Subtasks based on filter "Epic link = xxx" Problem : actually Structure is is someway hacking Jira , since by their definition, subtasks are not suppose to have Epic Link field. What happen is when we edit a ticket, Jira will automatically remove Epic Link. Then Structure Synchronizer will put them back again... but not always. Current Workaround : I need to daily Run a Full Resynchronization "Structure > Jira Agile" and warn the team, anytime they edit a ticket, the Epic Link will be back only next morning... Solution : could incremental synchronization be set in direction "Structure > Jira Agile" Unless i am wrong, it seems it's by default "Jira Agile > Structure"

Answering to myself Using : issue in structure('our structure', 'ancestor or issue = PRJ-1134') instead of Epic Link is much more reliable and filter and build dashboard of subtasks based on Epic. Thanks!

Again, no one using Cloud is helped by this, and is why we need Atlassian to include the basic functionality itself.

Dave Meyer Atlassian Team Jan 23, 2017

Hi @edgar lopez,

See my answer from January 13 – we have just released a native solution to this in JIRA Cloud.

Dave Meyer

Senior Product Manager, JIRA

This works for me:

"Epic Link" = XXX-### OR parent in issuesWhereEpicIn("key=XXX-###")
Carsten H I'm New Here Thursday

This is the only workaround that worked for me on 7.8.0. Thanks!

I want to do the same thing. Did you ever find a solution? I suspect there is none at the moment.

see my answer below (

We looked at purchasing the JQL Tricks plugin ( https://marketplace.atlassian.com/plugins/com.j-tricks.jql-plugin ) since that has the ability to do advanced JQL... but we never bought it because my users started using labels instead and manually updating labels. There was another plugin that could do advanced JQL queries, but I don't remember what it is. )

I am looking for a similar solution. I need a query that lists all Storys linked to an epic AND Subtasks of those Storys. Is this not possible? None of the suggestions here work for me. 

Did you ever get a solution?  I'm in the same boat.  I'm trying to create a Dashboard that will show me all Epics and their associated Stories and pertinent information about those stories.  You would think this should be so easy to do but apparently not!  smile

I just added a solution and hope it helps 

After reseraching a lot finally found the following solution

I wanted to create a JQL to show all issues , stories and specially subtasks related to an epic and then have it on the Agile board. The subtask part is what you dont get out of the box
I wanted to do it without any paid plugin like j-trick or Script Runner which can do this very easily

tempoEpicIssues didnt work for me since i am not on OnDemand.

Following is the soluition

1)Install Free SQL for Jira plugin. This is awesome plugin which gives you how to query jira database directly and then used the functionality where you can pass JQL inside a SQL function. The possibilities are unlimited here :)
https://marketplace.atlassian.com/plugins/com.kintosot.jira.jdbc4jql/server/overview

Then you can do something like this to pull all issues and subtasks. I think we can optimize this more 

project = PROJ AND issue in linkedIssues(PROJ-XXX) OR parent in sql("select key from issues where jql='project = PROJ AND issue in linkedIssues(PROJ-XXX)'") OR "Epic Link" in linkedIssues(PROJ-XXX) ORDER BY Rank ASC

this part was something which you cannot do without a paid plugin

  •      parent in sql("select key from issues where jql='project = PROJ AND issue in linkedIssues(PROJ-XXX)'")

Happy to read SQL for JIRA was useful to resolve this. Do not forget please to rate/review it smile 

This seems very cool, sadly I'm using the OnDemand version and this plugin is not available for that.  Neither is Script Runner, nor any of the other cool plugins that make this work. Does anyone have an alternative for OnDemand?

I am also using OnDemand the seeing: Unable to find JQL function 'tempoEpicIssues(XXX-XXX)'. Reading through the rest of the thread but do not see a workaround without a plugin.  I am part of a very large business with company JIRA Admins who are overwhelmed with the simple administration of JIRA for our company and cannot respond to requests for random plugins.  This seems like a simple query that should be supported OOTB.  Can anyone update?

This is not a solution, this is a hack. 

0 vote

Hi Nathan,
I have been trying to get results based of 1 single JQL, but I'm afraid this simply is not possible. Could you explain what exactly it is you are trying to accomplish, perhaps there is another solution.

I have a Greenhopper board and I want all tasks and subtasks for each of my epics to show up in an epic swimlane (one swimlane per epic).

So... I created a swimlane called "Build Foobar" and I have an epic called "Build Foobar" that has issue key of PRJ-1134. I was hoping to get all issues to show up in the "Build Foobar" swimlane (easy peasy) AND all those issues' subtasks (pain).

I know I can do this with labels... but I was trying to avoid creating labels since it requires my developers to use the right label everytime they create a subtask to an issue.

We looked at purchasing the JQL Tricks plugin ( https://marketplace.atlassian.com/plugins/com.j-tricks.jql-plugin ) since that has the ability to do advanced JQL... but we never bought it because my users started using labels instead and manually updating labels. There was another plugin that could do advanced JQL queries, but I don't remember what it is.

Nathan,

I use the Craftware plugin Search Linked Issues for JIRA and do that query like this:

("Epic Link" = CP-32236 OR issue IN subtaskIssuesFromQuery("cf[11960]=CP-32236"))

Where cf[11960] is the id of my Epic Link field.

Just as your users are, my users are building labels or issue links back to the epic to help find things but hopefully i'll be able to show them ways to save time as we get used to these capabilities.

There is no need for any Plugin..

Switch to "advance" filter option and enter

status in ("Open") AND parent in (PHX-xxx,ENG-xxx)

It will give you all the open tickets present as a subtask in parent JIRAS. Build more complex and enjoy using JIRA. Advance filter options will also give you all possible values to build Queries.

Please comment if its helpful.

Regards.

Hassan Saleem

Quality Control Engineer

Wellogic. U.A.E

Hassan, I think the ask was to isolate all issues and the subtasks of the issues associated to the epic, not just the issues and subtasks associated to the epic. Your example neglects to include the subtasks associated to the issues..

Anyone else find out an answer to accomplish this in JQL?

I did run into the Links Hierarchy plug-in (which looks rad), but looking for a non-plug-in solution at the moment. :)

Hi

On the similar lines, i want to get all stories for multiple epics and person working on those epics

below query is giving me error!! it is not allowing multiple values for Epic Link!!

project = TEST AND issuetype = Story AND "Epic Link" = (TEST-1275,TEST-955,TEST-966) AND "manager" = userid ORDER BY description

"manager" is in Epic, not in story.

Can somebody help with this query, Appreciate it.

thanks

Raj, the Epic link can't equal multiple values (each issue is in one Epic), but you can return issues in one of many Epics. e.g., "Epic Link" in (TEST-1275,TEST-955,TEST-966)

Erik

Thanks that worked well, appreciate your help.

I have an epic containing about 20 issues, but the JQL parent = XXX-1234 returns nothing at all.

yeah, you're dealing with the same thing i am i believe. there is a different between 'linked issues' and 'issues in epic'. to return the linked issues, try...


issue in (linkedIssues(AAA-###))   

BUT for all the 'issues in epic'... i've yet to find a string that returns those issues. 

then again, looks like i found a way to show them all. issue in (ABC-123, linkedIssues(ABC-123)) OR "Epic Link" = ABC-123 this will show all linked issues, issues in epic and even return the parent epic in the list as well. i use this for a confluence page.

Nearly... Doesn't return sub-tasks of stories however.

I'm also looking for a non-plug-in solution. Did anyone manage to solve this using raw JQL? 

Also try:

"Epic Link" =<Epic ID> AND  issuetype in (Story, Sub-task) OR issuekey in tempoEpicIssues(<Epic ID>) ORDER BY Rank

 

I'm getting the following error when trying this:

project = "xxx  xxx" AND "Epic Link" = xxxx-### AND issuekey in tempoEpicIssues(xxxx-###)

 

Error:  Unable to find JQL function 'tempoEpicIssues(xxxx-###)'.

 

Note: xxx=actual text I'm trying to query for but left out for privacy reasons

Hi Janelle

 

I have modified the sql : 

"Epic Link" =<Epic ID> AND  issuetype in (Story, Sub-task) OR issuekey in tempoEpicIssues(<Epic ID>) ORDER BY Rank

 

Here is what I have in my filter:

"Epic Link" = RSYS-550 AND  issuetype in (Story, Sub-task) OR issuekey in tempoEpicIssues(RSYS-550) ORDER BY Rank

and I'm receiving the same 'unable to find JQL function 'tempoEpicIssues..."

Is JQL function standard with Jira?

 

thanks for all of the help,

Janelle

Hi

JQL is function standard with Jira.

I am using this version :  JIRA v6.4.11.

What JIRA version are you on also do you have the tempo plug in for your timekeeping?

Thanks,

Malcolm

i'm sending a note to our JIRA admin to find out about the plug in.  thanks a million for your help!

No doubt things change along the time, and today, there are new plugins able to resolve it in the wink of an eyelike SQL for JIRA. It transforms any JQL into a SQL.

Not only that. It is also able to summarize regular and custom issue fields, create visual reports, etc. f course, and transform SQL into JQL again. So you are able to resolve ANY report like this and surely anything you could imagine.

 


 

I am still looking for an solution to use with OnDamand.

@Alan Fitzgerald it Looks like in the latest version of JIRA (7.2.1 specifically) Epic Link now includes subtasks as well, I'm still looking for official confirmation of that though.

The OnDemand version (not sure the version) still doesn't support it today.

Maybe it's just a caching issue. I noticed that, since the update, on boards that filter by Epic Link, only newly created subtasks in the epic are shown.

Hi, I have a similar problem and wondering if anyone can help. I want to add a quick filter that will display all stories that roll up into an initiative. I can get stories that roll up into a specific Epic, but cannot get back stories that roll up into an initiative. Much appreciation.

Hi,

This is very old question but this may useful to others, this answer work for me but we need to install ScriptRunner plugin to get JQL functions

"Epic Link" = "epicname" OR issueFunction in subtasksOf('"Epic Link" = "epicname"')

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

689 views 6 13
Read article

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