The best way to get nested items for all types of jira issue

Hi!
The problem: calculate progress based on children’s status.

Long story short:
Jira cloud has at least 3 different “nested items” setups:

  1. Subtasks
  2. Issues in epic
  3. Child items for custom levels in Jira Premium.
    3.5. Child items+subtasks in the same issue.

Subtasks are listed in the body,
Child items can be get though jql “parentLink=%”
Nextgen project items can be fetched with “paren=%”

Is there a unified way to get nested items by Jira issue ID?

Thx

@AndyJames,

Thanks for explaining your situation. The bad news is the mechanisms you described for “nested items” are all going to be deprecated per:
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-hierarchy-levels/

The good news is there is now a new attribute, parentId that is unifying the concept “hierarchy” in Jira. Aside from deprecation, you can learn more about the APIs for hierarchy in this developer announcement:

2 Likes

Thanks for the response!
I think, it will not be a problem for us, as we don’t care about the hierarchy level.
The question rather:
How to get nested items for any issue?

Maybe there is a hidden api method “GET /NestedElements” which returns everything for epic, task or a custom level created for roadmap?

Hi Andy,

There isn’t any good way to solve the problem. What is more you need to resolve ( find out) what is the clause for parentLink in meta, because it may be translated, so you need to fetch rest/api/2/field first. Then you also need to know if you are in a next-gen project (team-managed project) so you need to fetch project, then a last you can call jql for child issues, then a jql for subtasks, etc…

Thx! This is what we do right now and it’s really shitty logic.
Btw, regarding the translations, some methods support accept lanugage Accept-Language - HTTP | MDN

@AndyJames,

Would JQL work for you? I think you should be able to ask for issues where parentId=ABC-123.

Don’t have this option, only the parent, parentLink, and parentEpic . Is it a new attribute?
In general, it works, but the condition is really complex.

That would be very interesting! However, it seems that it is not working yet

{
    "errorMessages": [
        "Field 'parentId' does not exist or you do not have permission to view it."
    ],
    "warningMessages": []
}
1 Like

@AndyJames

I write the following JQL query to get the children of an issue in a unified way where it doesn’t matter what the parent-child relationship is:

parent=SOME-KEY OR "Epic Link"=SOME-KEY OR "Parent Link"=SOME-KEY

parent covers Task-Subtask and Epic-Task relationship in Team Managed Projects (TMP) and Task-Subtask relationship in Company Managed Projects (CMP)

Epic Link covers Epic-Task relationship in CMP

Parent Link covers Feature-Epic and above with Advanced Roadmaps

To get all the childrens’ children in one query I use webhooks to save the parent keys of each issue in an entity property called allParentIssues. That way I can search allParentIssues = SOME-KEY and get all the children and childrens’ children, and children’s childrens’ children ect in one query.

1 Like