Example scripts
To homepage
Jira

Summing Tempo Worklogs with an Attribute
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.0 - 8.6)

ScriptRunner For Jira (5.6.14)
Language |
groovy
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(worklog.id, attribute.id).returnedValue
}
// Sum the overtime in seconds. If there aren't any overtime worklogs, just return null
overtimeLogs.sum { Worklog worklog ->
worklog.timeSpent
} as Long
Having an issue with this script?
Report it here