Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Count Number of Subtasks and put on parent's custom field

 

I'm currently working on burnup chart to see the count of subtasks of each story.

So, I'm thinking about automate the count of subtasks each time a subtasks created, then put it on Custom Field of the parent, let's say `Number of Tasks`.

I've been looking and didn't found any beginner advise how to do this. Any help will be appreciated 

2 answers

1 accepted

0 votes
Answer accepted

Something like this should work in a number Script Field to count the number of subtasks for each issue. 

if (issue.getIssueType().name != "Sub-task") { // only calculate this for non-subtask issues
def subTaskSum = 0
issue.getSubTaskObjects()?.each { subtask -> // go through all subTask issues
subTaskSum += 1
}
return subTaskSum
}

 Regards,

Josh

Works great, thanks Josh

@Joshua Yamdogo _ Adaptavist This is great! 

Is it possible to filter this to only count specifically depending on subtask issue type?

Like Benjamin Dorsey likes this

How can we modify to count only sub-tasks of certain status? 

Hi, 

You have to use the Scriptrunner plugin to create a plugin which runs on issue created event.

The script should be able to fetch the links using the issueLinkManager. The getOutwardLinks() method will fetch you all the child links for that specific issue.

-Praveen

Hi Praveen,

Thanks for the reply. And yes, I do eventually use Script Runner. What I've been doing is creating new custom field that automatically fetch the child / subtasks of current issue and you can further filter is for resolved only.

But I didn't use the issueLinkManager, can you give me some example so that this might be one of the alternative, hopefully more efficient, answer

Hi, 

I hope you are using the post function script for this. Please check this for some example.

-Praveen

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

269 views 2 5
Read article

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