Date: Thu, 28 Mar 2024 14:39:39 +0000 (UTC) Message-ID: <445943146.9.1711636779806@c25ee9cf9701> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8_1086412477.1711636779806" ------=_Part_8_1086412477.1711636779806 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This article is for Tempo for Data Center.
The script snippets show you how to get the value of the Team custom fie= ld 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 fi= eld 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 ac= cess 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 =3D Logger.getLogger("com.onresolve.jira.groovy") myLog.setLevel(Level.DEBUG) def IssueManager =3D ComponentAccessor.getIssueManager() MutableIssue issue =3D IssueManager.getIssueObject("WIKK-20") def customFieldManager =3D ComponentAccessor.customFieldManager def teamField =3D customFieldManager.getCustomFieldObjects(issue).find { it= .name =3D=3D "Team" } if (!teamField) return; def team =3D issue.getCustomFieldValue(teamField)
Now you can output the Tempo Team field
myLog.i= nfo("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 tem= poteamobject =3D 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
def new= team =3D "GreenCloud Tango" issue.setCustomFieldValue(teamField, newteam) ComponentAccessor.issueManager.updateIssue(ComponentAccessor.jiraAuthentica= tionContext.getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, fa= lse)
WIth the version of Tempo Teams 8 and above the behaviour of the Tempo T= eam custom field changes. Now will
myLog.i= nfo("Team: " + team)
return the Team custom field name and the following wil= l now throw an error:
def tem= poteamobject =3D teamService.getTeam(team.toInteger()).getReturnedValue() myLog.info("Tempo Team name: " + tempoteamobject.name)
You will now be able to access the Tempo Team information with:
myLog.i= nfo("Tempo Team name: " + team.name + " with an ID: " + team.id)
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:
def new= team =3D teamService.getTeamByName("Custom Web Development").getReturnedVal= ue() issue.setCustomFieldValue(teamField, newteam) ComponentAccessor.issueManager.updateIssue(ComponentAccessor.jiraAuthentica= tionContext.getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, fa= lse)