Summing Tempo Worklogs with an Attribute


Tempo allows to categorise worklogs with additional attributes. With this script, collect all worklogs in an issue with a specific attribute value and show a summary of them in a script field.


As a billing administrator, I want to check the total overtime that employees have worked on an issue. Employees register overtime in Tempo by creating a worklog and checking an "Overtime" checkbox. I can use this script to see the sum of all overtime registered for each issue, and have that data displayed in a script field.

Good to Know

  • This script requires Tempo Timesheets.
  • Create a worklog attribute with "Overtime" as the key and "CHECKBOX" as the type.
  • Use 'Duration (time-tracking)' as the template for the custom script field and 'Duration Searcher' as the searcher.


  • Jira Jira (8.0 - 8.6)
  • ScriptRunner for Jira ScriptRunner for Jira (5.6.14)
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.worklog.Worklog import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.tempoplugin.core.workattribute.api.WorkAttributeService import com.tempoplugin.core.workattribute.api.WorkAttributeValueService @WithPlugin("is.origo.jira.tempo-plugin") @PluginModule WorkAttributeService workAttributeService @PluginModule WorkAttributeValueService workAttributeValueService def worklogManager = ComponentAccessor.worklogManager // Get the worklogs of the issue def worklogs = worklogManager.getByIssue(issue) // Filter the worklogs which are marked as "Overtime" def overtimeLogs = worklogs.findAll { worklog -> def attribute = workAttributeService.getWorkAttributeByKey("_Overtime_").returnedValue workAttributeValueService.getWorkAttributeValueByWorklogAndWorkAttribute(, } // Sum the overtime in seconds. If there aren't any overtime worklogs, just return null overtimeLogs.sum { Worklog worklog -> worklog.timeSpent } as Long
Discovered an issue? Report it here

Suggested for you

Appears in these Collections