Problem with comparing durations

Alexander Makarovsky December 2, 2024

Hi there! I have a task to track when time spent by specific developer exceeds original estimate.
What I've done is created a custom field named "dev-total" using JCMF Calculated (scripted) Duration Field with formula:
employeeKey = issue.get("customfield_12116")?.key; worklogs = issue.get("worklog")?.findAll({it.authorKey == employeeKey }); return worklogs.sum(0, { it.timeSpent });

where customfield_12116 is a field where developer is assigned.
Field works perfectly fine.

Than I've created an automation rule with compare condition.
Screenshot 2024-12-03 at 0.09.54.png
And it doesn't work. It performs even if time spent by a developer is less than original estimate.

What am I doing wrong?

1 answer

1 accepted

4 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 2, 2024

Hello @Alexander Makarovsky 

As a debugging step you should print each of those smart values into the rule Audit Log so that you can see if the values being compared are what you expect.

You can print information into the Audit Log using the Log action in the rule.

Alexander Makarovsky December 2, 2024

Nice! Thank you!
I've done it and it seems {{issue.originalestimate}} returns nothing
Screenshot 2024-12-03 at 1.04.59.png

Alexander Makarovsky December 2, 2024

ok, now I understand. It was a simple mistake, since smart value for Original estimate should be issue.timetracking.originalEstimate
Problem solved.
Thank you so much!

Like Trudy Claspill likes this
Alexander Makarovsky January 28, 2025

@Trudy Claspill Hi! Unfortunately, what I've done above after you kind advice didn't resolve an issue. I've managed the syntax thing and now I have both fields in automation rule to show perfectly.
Still the rule performs even if logged time is less that original estimated. I'm afraid this is because of format difference showed below.
Would be thankful for ideas on how to edit Groovy formula to make my custom field return the value of logged hours in the same format as Original estimate.
On the screenshot is the task with 1 hour logged.
Screenshot 2025-01-29 at 2.09.45.png

Trudy Claspill
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 28, 2025

What are the smart values you are using when printing "estimate" and "log"?

Alexander Makarovsky January 28, 2025

estimate - {{issue.timetracking.originalEstimate}}, log - {{issue.fields.dev-total}}

Where dev-total is JCMF Calculated (scripted) Duration Field with formula:
employeeKey = issue.get("customfield_12116")?.key; worklogs = issue.get("worklog")?.findAll({it.authorKey == employeeKey }); return worklogs.sum(0, { it.timeSpent });

where customfield_12116 is a field where developer is assigned.

Trudy Claspill
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 29, 2025

I don't have a data center instance to try this, but what if you use originalEstimateSeconds instead of originalEstimate?

Like Alexander Makarovsky likes this
Alexander Makarovsky January 29, 2025

Yes!!! Couldn't imagine to solve this from such angle. Thank you so much!

Like Trudy Claspill likes this

Suggest an answer

Log in or Sign up to answer