Forums

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

How to count subtasks in a story, but only of a particular issue type?

Mo January 11, 2021 edited

I have 3 subtasks (each a different issue type - one of each issue type is in each story), and a 4th issue type of subtasks get added in various quantities on each story.  

So let's say, upon transition of subtask issue type #2, I need issue #3 to be created with something showing the sum of all #4 issues within the same story. 

  • subtask issue type #1 - typically 1 for every story
  • subtask issue type #2 - typically 1 for every story
  • subtask issue type #3 - typically 1 for every story
  • subtask issue type #4 - QTYs vary for each story

Preferrably this number would be in the summary after the standard name, but if i have to make a custom number field, that would be fine too.

Alternatively, this could count the number of issues in Ready status versus count of the issue type, since up to this transition, the previous 3 subtasks would be closed.

*Notes:  I've already got #3 creation automation running upon closing #2--just looking for how to update automation to get the sum as described.  Also, looking for solutions without scriptrunner or other plugins please.

Thanks in advance for the help!

3 answers

1 accepted

2 votes
Answer accepted
Gareth Cantrell
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.
January 12, 2021

Hi @Mo 

You can do that quite easily using automation in Jira Cloud, by using the Lookup issues action.

The following screenshot shows an example rule which you can run manually against a sub-task.

The {{lookupIssues}} smart value returned by the action is a list and therefore you can run any of the list functions against it; in this case I'm using .size() to count the number items in the list.

Screenshot 2021-01-12 at 16.37.18.png

Mo January 19, 2021

@Gareth Cantrell thank you so much!! This worked perfectly!!!

Like • Gareth Cantrell likes this
0 votes
Kate Kabir
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.
January 12, 2021 edited

Hi Mo

Thank you for the question.

I can confirm that to sum up the values on a subtask on a parent issue that we have the example script located in the documentation page here which provides an example of how to store the number of subtasks below the parent issue on the parent issue.

The first way is to use the built-in Create SubTask post function which the plugin provides and is documented here. This post function will create a single subtask when it is executed and so would not be capable of creating a random number of subtasks.

Continue..

Kate Kabir
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.
January 12, 2021

The second way to achieve this requirement would be to write your own script and to place this inside Run Script post function which is documented here. This approach would allow you to create a custom script with some logic to create a subtask which could be executed multiple times depending on the number in your multi-select field selected values.

Continue..

0 votes
Kate Kabir
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.
January 12, 2021

Hi Mo

Thank you for the question. 

I can confirm that to sum up the values on a subtask on a parent issue that we have the example script located in the documentation page here which provides an example of how to store the number of subtasks below the parent issue on the parent issue.

The first way is to use the built-in Create SubTask post function which the plugin provides and is documented here. This post function will create a single subtask when it is executed and so would not be capable of creating a random number of subtasks.

The second way to achieve this requirement would be to write your own script and to place this inside Run Script post function which is documented here. This approach would allow you to create a custom script with some logic to create a subtask which could be executed multiple times depending on the number in your multi-select field selected values.

To do this, you would create a Groovy Times Loop which loops over the number of times as you want to create a subtask for which will be the number returned by the multi-select field and then you can add his logic to create the subtask inside this loop.

I can confirm that to help with approach 2 that we have a script located here which can be run on the Script Console to create a subtask along with some example scripts of how to get custom field values located
here and you will be able to use these scripts to help you create your post function scripts to create subtasks.

One thing to consider with your requirement is that ScriptRunner has a timeout meaning that all scripts must execute within 60 seconds otherwise they will be terminated to prevent causing performance impacts. This means that if you create a lot of subtasks from one post function then you may hit these timeouts.

Thank you.

Kind regards,
Kate

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events