Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL to query parent record based on specific sub task

Vimalraj
Contributor
July 16, 2020

Hi,

I'm looking for solution to search a parent record based on specific sub-task.

For ex., 

Parent issuetype has 2 different sub tasks. Sub task 1 is an Action and Sub task 2 is a Question.

My requirement to is fetch parent records which has only contains Actions. Is there a way to do it. 

I tried below, but doesnt seem to work. May be I'm making some mistake

 

issuetype = "Parent" AND issueFunction in parentsOf("issuetype = 'Action' AND issuetype != 'Question'") 

Please assist.

2 answers

1 accepted

1 vote
Answer accepted
Italo Qualisoni [e-Core]
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.
July 16, 2020

This is tricky, you can try the following:

 

issuetype = Parent AND issueFunction in parentsOf("issuetype = 'Action'") and (not issueFunction in parentsOf("issuetype = 'Question'"))

 

I'll try to break it down, this intend to return all issues with issuetype = Parent that contains subtasks with issuetype Action and doesn't have any Question subtask. 

It's important to notice that that not in the second part of the condition.

I think this might be a heavy query depending of the amount of issues you have, maybe you can improve the performance by adding the project = ProjectKey , this will reduce the scope of the JQL. I had an issue in the past that a heavy query was crashing an environment due large usage of memory, probably this has been fixed in recent versions but I need to share that heavy JQL can impact performance. So use it as needed :)

2 votes
Jack Nolddor _Sweet Bananas_
Atlassian Partner
July 17, 2020

Hi,

Sadly you cannot achieve the desired search using standard features on Jira, you must go for a third-party app instead. Using i.e. JQL Booster Pack (if you are on Server / DataCenter) you can type the following:

 

1) Fetch parent records which has only contains Actions

type = Parent AND issue IN parentsOf("type = Action") AND issue NOT IN parentsOf("type = 'Question")

 

Or using Script Runner for Jira:

type = Parent AND issueFunction IN parentsOf("type = Action") AND issueFunction NOT IN parentsOf("type = 'Question")

(*) Note that this is just an example, you must tune above query to fit your needs.

 

Regards

Vimalraj
Contributor
July 17, 2020

Thanks @Jack Nolddor _Sweet Bananas_ @Italo Qualisoni [e-Core] @Jack Nolddor _Sweet Bananas_ @Italo Qualisoni [e-Core] for your response. It helped. I understand that it is a heavy query. Issuetype i'm searching is specific to a project and field context is set to the project. Hopefully it should not hurt the performance.

Suggest an answer

Log in or Sign up to answer