To learn more about Tempo products, please visit our Help Center. For support, see our Support Portal.

Tempo Team custom field

The script snippets show you how to get the value of the Team custom field of an issue and how to write a Tempo team into a Jira issue.

With the version 8 of Tempo Teams (included in Tempo Planner Version 8, Tempo Budgets Version 14 and Tempo Timesheets Version 11) the Tempo Team field has been converted into an object. Previously (Tempo Teams 6 and older) the Tempo Team field was returned with an ID of the Tempo team.

In all cases you should import the following dependencies and you can access the Tempo custom field on an issue as follows:

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.fields.CustomField import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.atlassian.jira.issue.MutableIssue import org.apache.log4j.Level import org.apache.log4j.Logger import com.tempoplugin.team.service.TeamImpl import com.tempoplugin.team.api.Team import com.tempoplugin.team.api.TeamImpl import com.tempoplugin.team.api.TeamManager import com.tempoplugin.team.api.TeamService import groovy.transform.Field import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import com.atlassian.jira.event.type.EventDispatchOption @WithPlugin("com.tempoplugin.tempo-teams") @PluginModule TeamService teamService def myLog = Logger.getLogger("com.onresolve.jira.groovy") myLog.setLevel(Level.DEBUG) def IssueManager = ComponentAccessor.getIssueManager() MutableIssue issue = IssueManager.getIssueObject("WIKK-20") def customFieldManager = ComponentAccessor.customFieldManager def teamField = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Team" } if (!teamField) return; def team = issue.getCustomFieldValue(teamField)

Now you can output the Tempo Team field

myLog.info("Team: " + team)

For Tempo Teams 7 and below this will return the Team ID. If you want to display e.g. the Team Name you will need to do

def tempoteamobject = teamService.getTeam(team.toInteger()).getReturnedValue() myLog.info("Tempo Team name: " + tempoteamobject.name)

To update an issue with a new Tempo Team you will need to

WIth the version of Tempo Teams 8 and above the behaviour of the Tempo Team custom field changes. Now will

return the Team custom field name and the following will now throw an error:

You will now be able to access the Tempo Team information with:

To update the Tempo team on an Jira issue you will need to declare/pass the Tempo team as an object. This can be done with: