How to calculate total time spent on stories,bugs and adding it to related Epic using Automations

Vineela Durbha
Contributor
January 10, 2025

Hi team,

We have stories/Bugs and there is time spent on each one . We need to import to the epic the time that are logged in the tasks (stories, bugs and spike) that are connected as "is parent task of" in the project.

We are looking to achieve this using automation rules and hence looking for some guidance on the same.

 I am trying something as below  but looks like its not working

 

Screenshot 2025-01-10 163439.png

2 answers

0 votes
Bill Sheboy
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 10, 2025

Hi @Vineela Durbha 

Please see this article and post for summing fields to a parent.  As you are using Jira Data Center, the REST API must be used to sum the time keeping fields because they are not yet supported by the Lookup Issues action.

https://community.atlassian.com/t5/Jira-articles/How-Can-I-Sum-Up-Multiple-Issues-into-a-Parent-Number-Field/bc-p/2883071#M16701

Kind regards,
Bill

Vineela Durbha
Contributor
January 13, 2025

Hi @Bill Sheboy 

I have tried lookup issues as below

Screenshot 2025-01-13 162334.png

But it is showing me errors in the audit log as below.

Screenshot 2025-01-13 162734.png

How to add the total timespent on all lookupissues and add it to Epic?

Like Anahit Sukiasyan likes this
Bill Sheboy
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 13, 2025

Please re-read the article and post I offered as the time tracking fields are not available with the Lookup Issues action with Jira Data Center's version of automation rules.  The REST API must be used to access and sum the fields.

Additionally, the syntax you are using is incorrect for the smart values.  When you review the other article you will see the correct syntax.

 

Vineela Durbha
Contributor
January 15, 2025

Hi @Bill Sheboy 
We are not sure if we can use REST API for this . So can we use smart values  like
Create a variable to get sum of original estimate 

{{#=}}{{issue.subtasks.original estimate.sum}} / 3600{{/}}

 

and set that field value to original estimate?

or a way on how to just get sub-tasks original estimate not the sum?

Bill Sheboy
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 15, 2025

That will work for summing Subtasks up to their parent Story as the smart value {{issue.subtasks}} should contain all possible fields of the issues.

 

It will not work for summing the Story values to the Epic: the REST API must be used to sum the time tracking fields for the update.

0 votes
Anahit Sukiasyan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 10, 2025

hi @Vineela Durbha

Yes you can achieve that by creating an Automation Rule, hope these steps will be helpful:

  1. Create a New Rule.

  2. Set the Trigger:

    • Select the Issue Updated trigger.
    • Configure the trigger to run when Time Spent is logged or updated.
  3. Branch Rule/Related Issues:

    • Add a branch for Parent Issue to target the Epic.
    • This branch ensures that changes in time spent on child issues (stories, bugs, etc.) are reflected in the Epic.
  4. Action: Sum the Time Spent:

    • Inside the Parent Issue branch, add the Edit Issue action.
    • Set the Time Spent field of the parent Epic by summing up the logged time from child issues.
    • Use this smart value for summing:
      {{issue.subtasks.timeSpent.sum}}
    • If you are not using subtasks but rather linked issues (e.g., "is parent task of"), use:
      {{lookupIssues.timeSpent.sum}}
  5. Fetch Related Issues (if using links):

    • Add a Lookup Issues action before editing the Epic.
    • Set the JQL to fetch linked issues:
      issue in linkedIssues({{issue.key}}, "is parent task of")
Bill Sheboy
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 10, 2025

Hi  Anahit Sukiasyan,

Once again, do not post bot / AI-generated content without disclosing the source.  Please carefully read the community guidelines as you continue to do this: https://community.atlassian.com/t5/custom/page/page-id/rules-of-engagement

Additionally, the automated answer you posted cannot work for Jira Data Center automation: the Lookup Issues action for that Jira version does not support the fields noted. 

Please confirm the validity of solutions you get from other sources before posting them to the Atlassian Community.  Thank you.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer