Forums

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

Query get all subtasks for a parent

Mkurama
Contributor
January 31, 2022

Hi,

I just want to write a JQL query to get number of all subtasks for a parent.

 

Any solution?

4 answers

3 accepted

0 votes
Answer accepted
Mkurama
Contributor
January 31, 2022

I already fix it by this code and it works with me:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("JOL-60")
def count = 0

issue.getSubTaskObjects().each{
count++
}

 Great thank you @Fabio Racobaldo _Catworkx_ 

0 votes
Answer accepted
Rilwan Ahmed
Community Champion
January 31, 2022

final Searchsubtasks = "parent = JOL-60" 
OR 
String Searchsubtasks = "parent = JOL-60"

Mkurama
Contributor
January 31, 2022

Thank you @Rilwan Ahmed for your response

0 votes
Answer accepted
Fabio Racobaldo _Catworkx_
Community Champion
January 31, 2022

Hi @Mkurama ,

you can use field parent to do that. Example :

parent = YOUR_PARENT_KEY_HERE

Through the above JQL, you will retrieve all subtasks associated to that parent key.

Hope this helps,

Fabio

Mkurama
Contributor
January 31, 2022

Hello @Fabio Racobaldo _Catworkx_ Thank you for your quick response.

I tried it in script runner to run the query but it return 0.

JQL.PNG

Fabio Racobaldo _Catworkx_
Community Champion
January 31, 2022

you missed an equal and project key should be in uppercase.

parent = \"JOL-60\"

Mkurama
Contributor
January 31, 2022

Unfortunately, It doesn't work. in my case

Fabio Racobaldo _Catworkx_
Community Champion
January 31, 2022

Please, could you try in search issues first and verify that it works?

Mkurama
Contributor
January 31, 2022

Yes. It works in normal search but I want to get number of subtasks for a specific parent in Script Runner. Ho it would be?

search.PNG

Fabio Racobaldo _Catworkx_
Community Champion
January 31, 2022

Please @Mkurama , share your scriptrunner code in order to fix your issue

0 votes
Rabi Kiran Roka
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2024

project = "Project Key" and parent =Parent Key ORDER BY created DESC

This Query helps from the Issue Lists

Suggest an answer

Log in or Sign up to answer