Automation RUle: sum of Time spent in Subtask and show them at Story level
Asked by Emna Elleuch:

I've asked a lot of questions regarding Time Spent sum and i couldn't find the right way so i've asked the team to come back to the original Jira workflow.

Basically, we receive Epic (from another platform which is integrated to JIRA), we add a Story and under each Story we add QA and DEV Substaks. The team log their time under QA And DEV Subtasks, The clock work App works as expected

now i'm looking to find a way to sum up all the time spent in QA and DEV Substask (or bugs) and display the sum at Story Level and then at Epic Level (we have added a custom field called Time spent).

I've tried the attached rule for 1 sub task (that works fine)but if i have 2 subtasks, how can i fix it?

Thanks in advance

![time spent.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/338330i207E758FC151426E/image-size/large?v=v2&px=999 "time spent.PNG")


Answers:
author: Tim Kopperud
body: Hi [@Emna Elleuch](/t5/user/viewprofilepage/user-id/4862258), I first posted an answer here which I noticed had to be incorrect, hence I removed it. After trying to rephrase it and add a new example I still didn't get it, and I think its because I dont fully understand your requirements. E.g. when you are saying
> I've tried the attached rule for 1 sub task (that works fine)but if i have 2 subtasks,

What does this exactly means?

I see under the Parent branch that you use {{issue....}} and not {{triggerIssue....}}. Do you try to copy the value from the Parent into "Time Spent" (then using issue is correct), or do you want to copy the value from the subtask into the Time Spent on parent issue (then triggerIssue is correct).

Do you want to simply overwrite Time Spent or accumulate to it? Is Time Spent meant to show the total accumulated end result on all child Issues?

On Stories we have a feature including subtasks.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/338338i15B982058B6275C2/image-size/large?v=v2&px=999 "image.png")

Is it so that you want to have Time Spent (red underscore) on the Story to be identical to Time Tracking (yellow marking)?

TimK


author: Adaeze_Jude_HEROCODERS
body: Hello [@Emna Elleuch](/t5/user/viewprofilepage/user-id/4862258) ,

Without needing an automation rule, you can get this information with Clockwork.

In Clockwork, you can display the total time tracked on Child issues by Clicking a button, as shown:

![2hyfu6WQTM.png](https://community.atlassian.com/t5/image/serverpage/image-id/338541i1BC4F6456E684D57/image-size/large?v=v2&px=999 "2hyfu6WQTM.png")

Also, this information is available on the Timesheet, as shown:

![opYi5n2Ege.png](https://community.atlassian.com/t5/image/serverpage/image-id/338548i1997EB2E2C33E17F/image-size/large?v=v2&px=999 "opYi5n2Ege.png")

I also discussed an automation recently that gets the total time spent on all linked issues.

![](https://downloads.intercomcdn.com/i/o/975749351/fe1836653b4c852770b7490b/image.png?
expires=1722261600&signature=709203b962b74a2baf8f1cc841cbbf8668f1550154bb541dd28576309c88d414&req=fSciEc13noReFb4f3HP0gKj3ypqAu1sdkRQJ
)![](https://downloads.intercomcdn.com/i/o/975758967/f6851c95497b8f415ea87da2/image.png?
expires=1722261600&signature=af72f207c91f226290f3b32cd38f8fa05af5a5e25b3814fae15c175f26466a9d&req=fSciEcx2lIdYFb4f3HP0gJnBYrqZ5jPfMLY5
)

```
This is the Webrequest used:
https://YOUR-INSTANCE -URL/rest/api/2/search?jql=parentEpic%3D{{issue.key}}%20or%20parent%3D{{issue.key}}&fields=timespent
```

If you would like to discuss this further, please reach out [here](https://herocoders.atlassian.net/servicedesk/customer/portals).


Tags: cloud

jira-cloud