sub-task count of a parent issue

Raju KC
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.
September 25, 2013

How to get a count number of sub-task within a parent issue through a JQL search and/or through a JIRA script field?

1 answer

1 accepted

3 votes
Answer accepted
MichałS
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.
September 25, 2013

Hi,

Scripted field code:

issue.getSubTaskObjects().size()

I do not thing you can return a number with JQL but you can get all subtask of an issue with

issueFunction in subtasksOf("subQuery");

Raju KC
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.
September 25, 2013

Thanks,

HOw to get count of specific sub-tasks only? I have more than one sub-tasks.

Like Svein Løvland likes this
MB
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.
September 25, 2013

Try iterating through the returned collection and checking the issue type of each subtask:

Collection<Issue> subTasks = issue.getSubTaskObjects();
IssueType issueType = ComponentAccessor.getConstantsManager().getIssueTypeObject("Bug");
int count = 0;
for (Issue i : subTasks) {
	if (i.getIssueTypeObject().equals(issueType)) // or some other check
		count++;
}

MichałS
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.
September 25, 2013

yes:

issue.getSubTaskObjects().findAll {
it.getIssueTypeObject()?.getName() == "task type name you want"
}.size()

I like it to be more Groovy'ish :D

Kate McAnespie July 31, 2015

1. How can this be nulled out, i.e. not show on screen if there is 0? 2. Is there a way to show the count of sub-issues of task type and display that count on a linked issue?

Like atlassian2018 likes this

Suggest an answer

Log in or Sign up to answer