JQL to get details of linked parent initiatives
Asked by Ron Becker:

With a query we search for all Epics in a project. At the same time we would like to retrieve the linked parent and some details of the parent initiatives.

- Can this be achieved when parents are linked via issue links (Implements).

- Can this be achieved when parents are linked via the Parent Link field from Portfolio?


Answers:
author: Ste Wright
body: Hi [@Ron Becker](/t5/user/viewprofilepage/user-id/1189315)

Using JQL without an add-on, you can do some searching - for example:

* **issueLinkType:** This allows you to search for all issues within one link type
* **issuekey in parentIssuesOf("ABC-123"):** This would allow you to search for the parent of one specific Epic. See more details on Portfolio JQL on [this page](https://confluence.atlassian.com/jiraportfolioserver/searching-for-issues-using-portfolio-details-940678957.html)

\^ This returns all the results though, rather than a subset. If you want to locate all the parents of a group of Epics, you need to be able to implement a sub-query into the JQL search, and you'll need an add-on for this such as [ScriptRunner.](https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=server&tab=overview)

With ScriptRunner, you can embed the sub-query, such as:

```
issueFunction in portfolioParentsOf("project = ABC and issuetype = Epic")
```

\^ This searches for all Initiatives above which are parents of all the Epics in project ABC. Similarly with linked issues you could have:

```
issueFunction in linkedIssuesOf("project = ABC and issuetype = Epic","implements")
```

----------------------------

Just to clarify, this would find just the Initiatives themselves. You can have both on one search filter by adding...

```
OR project = ABC and issuetype = Epic
```

...to end of the query.

Ste

comments: author: Seb Sidbury
body: Just to add to Ste's helpful note, for anyone looking to solve this challenge in Jira **Cloud** , the **portfolioParentsOf()** function is not currently available in [ScriptRunner for Jira Cloud](https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=cloud&tab=overview) as the API to implement this function does not exist in Jira Cloud.

However **linkedIssuesOf()** is included in ScriptRunner for Jira Cloud, as well as in [Enhanced Search for Jira Cloud](https://marketplace.atlassian.com/apps/1221331/enhanced-search-jql-subqueries?tab=overview&hosting=cloud) for those not requiring the scripting functionality of ScriptRunner.

Seb (Adaptavist)


author: Ron Becker
body: Thanks for your help. Scriptrunner solved the problem.


author: Jack Nolddor [Sweet Bananas]
body: Hi Ron,

In addition to previous responses you can achieve the desired results using i.e. [**JQL Booster Pack**](https://marketplace.atlassian.com/vendors/1213300/sweet-bananas) as well, instead of using Script Runner if your application is self-hosted.

<br />

Some examples here:

*- Can this be achieved when parents are linked via the Parent Link field from Portfolio?*

    issue in portfolioParentOf("project = XXXX and type = Epic")

*- Can this be achieved when parents are linked via issue links (Implements).*

```
issue in linkedIssuesOf("project = XXXX and type = Epic","implements")
```

Using this app you can also query other issues relations, check:

* [epicsOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1146191874)
* [hasSubtasks()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1206223047)
* [issuesInEpics()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1182695645)
* [linkedIssuesOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1182695732)
* [parentsOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/774406164)
* [portfolioChildOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1212547088)
* [portfolioParentOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/1212547134)
* [subtasksOf()](https://sweetbananas.atlassian.net/wiki/spaces/JBP/pages/774275101)

References:

* [Official documentation](https://sweetbananas.atlassian.net/wiki/spaces/JBP/overview)

Hope this helps you to create awesome queries \<3

Kind regards


Tags: advanced-roadmaps

issue-link

jql

server