This page gives some guidance on how to use ScriptRunner to work with Tempo Timesheets for Jira, to accomplish some basic scripting requirements, such as:

  • sum worklogs with a specific attribute, for example to display on the issue the amount of Overtime

  • aggregate worklogs

  • auto-create worklogs

The cornerstone of this is the two annotations discussed in Scripting Other Plugins, namely @WithPlugin and @PluginModule .

Let’s dive straight into the examples.

These examples use Tempo Timesheets for Jira version 8. For information that works in version 7, see previous versions of this page.


Summing worklogs with an attribute

Tempo allows you to categorize worklogs with additional attributes. Let’s say we have a checkbox attribute called Overtime, and we’d like to display the total overtime on each issue.

We configure the Overtime attribute, as in the following example:

Set up a custom scripted field. In this example I’m going to call it Total Overtime. Make sure to use the Duration Searcher as the Search template.

The custom field script is:

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


WorkAttributeService workAttributeService

WorkAttributeValueService workAttributeValueService

def worklogManager = ComponentAccessor.getWorklogManager()

def worklogs = worklogManager.getByIssue(issue)

def overtimeLogs = worklogs.findAll { worklog ->
    def attribute = workAttributeService.getWorkAttributeByKey("_Overtime_").returnedValue

overtimeLogs.sum { Worklog worklog ->
} as Long
// if no overtime worklogs just return null

Use a custom template so that the duration is presented nicely, but note that we return a Long value so the duration searcher can index it properly:

Custom Template

#if ($value)




Duration Searcher

If configured properly we should be able to search for issues where the overtime has exceeded 4 hours using: "Total Overtime" > 4h.

Automatically adding a worklog

See an example script for this on the Adaptavist Library.

Population of the dropdown

See an example script for this on the Adaptavist Library.