Does ScriptRunner Enhanced Search support nested issueFunctions?

Darryl Lee - CCC February 1, 2020

Hi all: I'm trying to do something similar to Open Parent Issues with All Subtasks Closed but in JIRA Cloud, using ScriptRunner Enhanced Search.

Here's the accepted answer for ScriptRunner running on JIRA Server:

project = PROJECT and issuefunction in parentsOf("issuefunction in subtasksOf(\"issuefunction not in parentsOf('type in subTaskIssueTypes() and status != closed') and status != closed and type in standardIssueTypes()\") and status = closed")

Unfortunately, SRES doesn't seem to like this:

Error in the JQL Query: Expecting ')' or ',' but got 'not'. (line 1, character 45)

I thought it might be the backslashes to escape the ", as it seems SRES is less picky about that. But when I remove the backslashes, I get: 

Field 'issuefunction' does not exist or you do not have permission to view it.

My actual query is slightly trickier, requiring even more quotes, but I've tried all kinds of variations on single-quoting, double-quoting, alternating between the two, and I still have no luck:

project = PROJECT AND issuefunction in parentsOf("issuefunction in subtasksOf("issuefunction NOT in parentsOf("type='production release subtask' AND status != approved") AND type="production release" AND status != approved ") AND status = approved ")

Does SRES support this kind of deep nesting? This non-nested query below almost gives me what I want, but for some reason still returns a parent issue that has subtasks that are Approved and Done. I would like to only get parents where subtasks are all in Approved status.

project = PROJECT 
AND type = "production release"
AND status NOT in ("done", "completed", "canceled")
AND NOT issueFunction in parentsOf("type='production release subtask' AND status!=approved")
AND issueFunction in parentsOf("type='production release subtask' AND status=approved")

I appreciate any insights. Thank you!

2 answers

0 votes
Darryl Lee - CCC February 3, 2020

I thought I might try the "hack" of trying to reference a saved filter, but I cannot get this to work:

issueFunction NOT in parentsOf("type='production release subtask' AND status != Approved")

Error:

found "NOT in parentsOf(", was expecting "issueFunction in parentsOf("\

I don't know if you can normally have a filter like that.

But yeah, everything's a little bit different in Cloud. Can anybody from the ScriptRunner team weigh in?

Or since nesting seems like a no-go, does anybody have thoughts on why this non-nested filter would still return parents that have subtasks with a Done status?

project = PROJECT 
AND type = "production release"
AND status NOT in ("done", "completed", "canceled")
AND NOT issueFunction in parentsOf("type='production release subtask' AND status!=approved")
AND issueFunction in parentsOf("type='production release subtask' AND status=approved")
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 10, 2020

Hi Daryll,

I can confirm that we have resolved your issue through the support ticket which you raised in our support portal.

Regards,

Kristian

Amy DeLima June 23, 2021

What was the solution?  I am running into the same issue trying to figure out how to get a nested query to work on Cloud. 

 

Looking to get:

1. All issues within an epic

2. All issues linked as "is dependent on" from that epic

3. All issues within epics from #2

 

Here is what I have for server that works:

(issueFunction in issuesinEpics("(issueFunction in linkedIssuesOf(\"issue=TEC-32919\", \"is dependent on\") AND issuetype = Epic)") OR issueFunction in linkedIssuesOf("issue=TEC-32919", "is dependent on") OR issueFunction in issuesInEpics("issue=TEC-32919")) AND status != Canceled AND type != Epic

 

This is what I'm trying with Cloud:

(issueFunction in issuesInEpics("(issueFunction in linkedIssuesOf("issue=TEC-32919", "is dependent on") AND issuetype = Epic)") OR issueFunction in linkedIssuesOf("issue=TEC-32919", "is dependent on") OR issueFunction in issuesInEpics("issue=TEC-32919")) AND status != Canceled AND type != Epic

 

Most of this function works with the exception of the nested query. 

 

Any help is greatly appreciated!

Like PhillipS likes this
PhillipS August 3, 2021

I am in investigation of migrating to Jira cloud and having a similar issues with nesting issueFunctions inside one another.

 

issueFunction in linkedIssuesOf("issueFunction in epicsOf("<some native JQL Query>")", "Structure parent") 

 

The error I get is the same as one from the original post:
"Field 'issueFunction' does not exist or you do not have permissions to view it."

PhillipS August 3, 2021

There is a work around posted on this forum:
https://community.atlassian.com/t5/Jira-Software-questions/Scriptrunner-issuefunction-within-another-issuefunction-s/qaq-p/1488870

That I am about to try out.  Basically, create the inner section as its own filter, and then nest that saved filter inside of the other filter you are trying to create.

I would assume the syncing time would potentially increase by 1x for each nested filter created (depending on the dependencies and what order they run in).  I'll let you know if it works out for me.

0 votes
Leonard Chew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2020

I have checked your original query (the accepted solution) and can confirm that it works on jira-server. Your problem therefore seems to be cloud related or is a specific problem on your system.

Suggest an answer

Log in or Sign up to answer