Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Nested ScriptRunner Enhanced Search query

Alain BEAULIEU
Contributor
May 25, 2023

Hi all,

We all know that the Epic-Story relationship is native in Jira and we use "Epic Link" to get the issues under an epic.

Here we have a sorta hierarchy like this:

Activity (custom issue type) - Epic - Story

... where we use a custom "Activity Includes" relationship between Activities and Epics. It's our way of grouping epics together. So we link epics to activities this way.

I have a Confluence report that uses a filter to bring the list of issues under all the epics that are under a given Activity. So I give it an activity id and it gets me all the issues under those epics. In Jira Server, this JQL works perfectly to achieve this:

issueFunction in linkedIssuesOf("issueFunction in linkedIssuesOf('id = prdlh-13295', 'Activity Includes')", "is Epic of") and issuetype = story and status != OPEN

It fails in Jira Cloud, and it fails in ScriptRunner Enhanced Search (SRES) because nested queries are not allowed in SRES. I was told I must create a filter with the inner/nested query first, save that, and then reference it in the outer query, like this:

"InnerQuery" filter: issueFunction in linkedIssuesOf("id = prdlh-13295", "Activity Includes")

"OuterQuery" filter: issueFunction in linkedIssuesOf("filter = 'InnerQuery'", "is Epic of") and issuetype = story and status != OPEN

The inner query returns the list of epics under the activity alright, but the outer query does not return anything, not even an error message. What am I doing wrong?

1 answer

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 25, 2023

Hello @Alain BEAULIEU 

The InnerQuery is providing you with a list of Epics.

Have you tried running just the first part of OuterQuery to confirm it returns something?

issueFunction in linkedIssuesOf("filter = 'InnerQuery'", "is Epic of")

The first part of the OuterQuery seems to be looking for issues that are linked to the Epic with the link relationship "is Epic of". That doesn't seem to be the way to get Stories that are children of the Epic, if that is what you intend. That seems like it might actually be getting the Activity issues. What are the inner and outer descriptions for the "activity includes" link type?

If you want to get the child issues of the Epics you first retrieved then you would need to do this instead:

issueFunction in issuesInEpics("filter = 'InnerQuery' ")
Alain BEAULIEU
Contributor
May 26, 2023
  1. "Have you tried running just the first part of OuterQuery to confirm it returns something?"
    1. Yes I have, and it returns nothing.
  2. "That doesn't seem to be the way to get Stories that are children of the Epic, if that is what you intend."
    1. Maybe, but it works well on Jira Server... I was just trying to replicate it on Jira Cloud
  3. "If you want to get the child issues of the Epics you first retrieved then you would need to do this instead"
    1. I tried what you suggested and it worked! A big thanks to you Trudy!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, ace, atlassian community event, donation, girls who code, women in tech, malala fund, plan international, kudos, community badge, badge, atlassian badge, International Women’s month, International Women’s Day, women's month, women's day

10 for Change at Atlassian Community Events

Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!

Join an Atlassian Community Event!
AUG Leaders

Upcoming Jira Events