Forums

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

Custom field showing the total time spent on all of an Epic’s subtasks

Álvaro Boza
February 18, 2026

Hello, I need to record in a field (to later perform calculations) the time logged on the subtasks associated with an epic when the epic is closed.

For example:
subtask1 = 1h,
subtask2 = 1h,

Then in the epic ticket, have a field showing 2h.

Would it be possible to do this with an automation? How would it be done?

Any help on this matter would be greatly appreciated.

Thank you very much.

3 answers

1 accepted

2 votes
Answer accepted
Arkadiusz Wroblewski
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 Champions.
February 19, 2026

hi @Álvaro Boza 

 

Hi @Álvaro Boza  

Because you only need this in one space/project and you want a numeric value stored on the Epic when it’s closed (so you can use it later for calculations), the best practice is:

Use Automation to roll up values from issues that are actually in the Epic (true Epic children).

If you also need to include issues from other projects that are only linked (Relates/Blocks/etc.), Automation becomes unreliable for aggregation, that’s where ScriptRunner is the better tool.

 

1) Best practice (Automation) works for Epic children (even cross-project, if they’re in the Epic)


You want a field on the Epic that shows:

Deviation = Logged time / Estimated time

Example: estimated 2h, logged 1h → 0.5

 

Create custom field(s)

On the Epic, create a Number custom field, e.g.:

Time deviation (Logged / Estimate)

(Optional but helpful for transparency/debugging)

Epic total logged hours (calc) (Number)

Epic total estimated hours (calc) (Number)

Automation rule (runs on Epic closure)

Trigger: Issue transitioned → Done/Closed
Condition: Issue type = Epic

Action: Lookup issues (get the Epic’s child issues)
JQL (works in many Cloud sites):

parentEpic = {{issue.key}}


Then: Edit issue fields (on the Epic)

Epic total logged hours (calc):

{{lookupIssues.timespent.sum.divide(3600)}}


Epic total estimated hours (calc):

{{lookupIssues.timeoriginalestimate.sum.divide(3600)}}


Time deviation (Logged / Estimate):

{{#if(lookupIssues.timeoriginalestimate.sum)}}
{{lookupIssues.timespent.sum.divide(lookupIssues.timeoriginalestimate.sum)}}
{{else}}
0
{{/}}


This will store 0.5 for your example (1h logged / 2h estimated).

Important note for your “linked tickets from other projects”

If those company-managed tickets are true Epic children (i.e., they belong to the Epic), they’ll be included by the lookup even if they’re in a different project.

If they are only connected via issue links (relates to/blocks/etc.), they will not be included by the Epic children lookup and Cloud automation isn’t great at summing worklogs across arbitrary linked-issue sets.

 

2) If you must include linked issues (not Epic children): use ScriptRunner

 

Since you do have access to ScriptRunner, that’s the right tool if you need:

Epic children plus

issues linked from other projects (and optionally their sub-tasks)

With ScriptRunner you can:

collect Epic children

collect linked issues (by link type)

sum timespent and timeoriginalestimate

compute timespent / timeoriginalestimate

write the result into your Epic custom field when the Epic transitions to Done

 

For your case:

Start with the Automation rule above and make sure the work items you want included are in the Epic (that’s the cleanest and most maintainable on Cloud). Only reach for ScriptRunner if you truly need to aggregate time from linked-only issues across projects.

Álvaro Boza
February 19, 2026

Hello @Arkadiusz Wroblewski !!!

Thank you very much for your help.

I just tested the automation and the following error occurred:

Captura de pantalla 2026-02-19 a las 9.58.50.png

I’m attaching a screenshot of the automation rule:

Captura de pantalla 2026-02-19 a las 10.00.01.png

Would I be missing anything else?

Álvaro Boza
February 19, 2026

I’m adding the type of fields configured:

Captura de pantalla 2026-02-19 a las 10.09.20.png

Arkadiusz Wroblewski
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 Champions.
February 19, 2026

@Álvaro Boza 

The error happens because “Time deviation” is a Number field, but the value your rule is trying to write is not being interpreted as a number at runtime (often because one of the source smart values is empty/null, or the calculation is evaluated as text).

To fix it, make sure your “Time deviation” edit uses a math block and converts inputs to numbers with a safe default:

In the “Edit work item fields → Time deviation” action, set:

{{#=}}
({{issue.customfield_<logged>.asNumber|0}}) - ({{issue.customfield_<estimated>.asNumber|0}})
{{/}}


Replace <logged> with the custom field id for Epic total logged hours

Replace <estimated> with the custom field id for Epic total estimated hours

.asNumber forces numeric conversion

|0 prevents failures when one of the fields is empty

If you are using “Lookup work items”

Because your rule does Lookup work items, you probably want the deviation based on the sum of the looked-up items. Then set:

{{#=}}
({{lookupIssues.customfield_<logged>.sum.asNumber|0}}) - ({{lookupIssues.customfield_<estimated>.sum.asNumber|0}})
{{/}}

Why it fails even though it shows “0”

Automation can still throw “cannot convert to number” if the expression actually evaluates to something like empty string, null, or text, even if the UI preview ends up showing “0”.

Álvaro Boza
February 19, 2026

I think the problem is with the summation of the task hours. I tried this variant that works with just 'issue' in another automation, but it doesn’t pick up any data—it returns 0: {{lookupIssues.timetracking.timeSpentSeconds.sum.asNumber|0}}

Álvaro Boza
February 19, 2026

Hello,

It finally worked with this:

{{#=}}{{lookupIssues.timetracking.timeSpentSeconds.sum}} / 3600{{/}}

Thank you so much for your help!

Best regards,

Álvaro

Like Arkadiusz Wroblewski likes this
Arkadiusz Wroblewski
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 Champions.
February 19, 2026

@Álvaro Boza 

Great to hear that :)

Like Álvaro Boza likes this
0 votes
Petru Simion _Simitech Ltd__
Atlassian Partner
February 18, 2026

Hi @Álvaro Boza ,

 

You can do this by creating a scripted fields, using Script Runner app.

You will loop through all epic children and sum up their logged time into this scripted field that will always display the total.

The good thing is that it works for future and already existing epics/children.

 

Regards, 

 

Petru

Álvaro Boza
February 19, 2026

Thank you for your reply!

I have ScriptRunner, but I’m not familiar with this tool.

Could you give me some guidance on how to get started with these tasks in this tool?
Petru Simion _Simitech Ltd__
Atlassian Partner
February 19, 2026

Hi @Álvaro Boza ,

 

On the left hand menu look for Scripted fields.

You will need to create a script that will be executed when the field renders.

For that you will need to add your field to screen -> screen scheme -> issue type screen scheme -> Project.

Script Runner provides you wihe examples how to code your script.

 

Regards, 

 

Petru

0 votes
Trudy Claspill
Community Champion
February 18, 2026

Hello @Álvaro Boza 

Welcome to the Atlassian community.

Do you really mean Subtask type work items, or do you mean the child items of the Epic? Subtasks cannot typically be directly connected to the Epic, but are instead children of standard work items that are children of the Epic.

Do you want to update this field as time is added to the items, or do you want to set it once only when the Epic is closed?

Álvaro Boza
February 18, 2026

Hi Trudy!! Thank you very much for your reply!!

Exactly, I meant the Epic’s child items, the Tasks, not the Subtasks.

I need it to be done once the Epic is closed, not as time is added.

Trudy Claspill
Community Champion
February 18, 2026

Hello @Álvaro Boza 

If you don't have the ScriptRunner app (suggested by @Petru Simion _Simitech Ltd__ ) then you could do this with an Automation Rule.

Are you familiar with Automation Rules?

Does this need to be executed for Epics in more than one project/Space?

Are the project/Space types where this is needed Team-managed or Company-managed?

Do you Epics have child items that are in different projects/Spaces than the Epic?

How do you want to see the data in the Epic? Do you want to see it in the Time Spent field so that it shows in the pretty format of weeks/days/hours? 

There is no native custom field type for "duration" that will display time in that same manner. If you want to put the time into a number (or text) custom field and display it in the pretty format you would have to manipulate the summed time from the child issues to figure out how many minutes/hours/days/weeks it is, as the information is stored internally in seconds.

If you want it displayed in the Epic's Time Spent field, then in the rule you would use a Log Work action to log the time against the Epic. However that could lead to problems if the Epic is reopened and closed again at a later date.

Álvaro Boza
February 19, 2026
Thank you both!

I will answer your questions below.

Are you familiar with Automation Rules?
Yes, I am familiar with Automation Rules.

Does this need to be executed for Epics in more than one project/Space?
Only for one space.

Are the project/Space types where this is needed Team-managed or Company-managed?
Initially, it will be for a Team-managed project, although the Epics may have linked tickets from Company-managed spaces.

Do your Epics have child items that are in different projects/Spaces than the Epic?
Yes, some of them may have links to tickets from other projects.

How do you want to see the data in the Epic?
My goal is to divide the estimated time by the logged time on the tasks to calculate the time deviation. For example, if 2 hours were estimated but the Epic was closed in 1 hour, the value that should appear in the Custom Field is 0.5.

I’m not familiar with ScriptRunner, but I do have access to the tool.

Suggest an answer

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

Atlassian Community Events