It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner query within sub-query...

...or how to use "issueFunction in parentsOf" as a sub-query for  "parent in".

background:
the releases process is where there is the main issue (i.e. Release v1.3) and sub-tasks for releasing to environments (i.e. TEST, UAT, PROD).

object:
i would like to create a query that lists main issues where any of the sub-tasks are not closed and for those main issues, list the associated sub-tasks (irrespective of status).

currently i have following solution:
(issueFunction in parentsOf("project = \"Release Process Project\" AND type = Sub-task AND status in (Open)") AND summary ~ "Stock") OR parent in ("REL-26473")

i'd like to dynamicaly update "REL-26473"

the 1st section of the query returns "REL-26473" and substituting "REL-26473" in 2nd section with 1st section doesn't work:

(issueFunction in parentsOf("project = \"Release Process Project\" AND type = Sub-task AND status in (Open)") AND summary ~ "Stock") OR parent in ("issueFunction in parentsOf(\"project = \"Release Process Project\" AND type = Sub-task AND status in (Open)\") AND summary ~ \"Stock\"")

any idea or suggestions? thanks in advance!

1 answer

1 accepted

0 votes
Answer accepted

Breaking it down ...

You want 

  1. All the parents of open sub-task matching certain parameters plus
  2. All the children (regardless of status) of the items in #1

So in JQL: 

issueFunction in parenstOf("query1") OR issueFucntion in subTasksOf ('issueFunction in parenstOf("query1")')

That may not be a very performant JQL, but this should work:

issueFunction in parentsOf("project = REL AND Type = sub-task AND status = Open AND summary ~stock") or issueFunction in subtasksOf('issueFunction in parentsOf("project = REL AND Type = sub-task AND status = Open AND summary ~stock")')

You might be able to speed it up by including a second project parameter in the sub-query

issueFunction in parentsOf("project = REL AND Type = sub-task AND status = Open AND summary ~stock") or issueFunction in subtasksOf('project = REL AND issueFunction in parentsOf("project = REL AND Type = sub-task AND status = Open AND summary ~stock")')

wicked, this works like a charm - thank you very much for your time and effort, very much appreciated!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

260 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you