Document toolboxDocument toolbox

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

Tempo Account information

The script shows you how you get the Tempo Account information from a Jira issue and extract additional information for the account (e.g. Account Category). It can be used to create a scripted field to inject the additional Account information into a Jira custom field.

import com.atlassian.jira.component.ComponentAccessor import com.tempoplugin.accounts.account.api.Account import com.tempoplugin.platform.jira.user.JiraTempoUser import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue import com.opensymphony.workflow.InvalidInputException import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue import com.opensymphony.workflow.InvalidInputException import com.tempoplugin.accounts.account.api.* import org.apache.log4j.Level import org.apache.log4j.Logger import com.atlassian.jira.component.ComponentAccessor import com.tempoplugin.accounts.account.api.Account import com.tempoplugin.platform.jira.user.JiraTempoUser import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin(["com.tempoplugin.tempo-accounts"]) def myLog = Logger.getLogger("com.onresolve.jira.groovy") myLog.setLevel(Level.DEBUG) def IssueManager = ComponentAccessor.getIssueManager() MutableIssue issue = IssueManager.getIssueObject("WIKK-26") def customFieldManager = ComponentAccessor.customFieldManager def accountField = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Account" } myLog.info("Accountfield on Issue: " + accountField) def account = issue.getCustomFieldValue(accountField) as Account myLog.info("Account on Issue: " + account) def accountcategory = account.category.getName() def accountcategorykey = account.category.getKey() def accountcategorytype = account.category.getCategoryType().getName() def accountleadusername = (account.lead as JiraTempoUser).applicationUser.name def accountleaduserkey = (account.lead as JiraTempoUser).applicationUser.key myLog.info("AccountCategory on Account: " + accountcategory) myLog.info("AccountCategoryKey on Account: " + accountcategorykey) myLog.info("AccountCategoryType on Account: " + accountcategorytype) myLog.info("Account lead : " + accountleadusername + " with userkey: " + accountleaduserkey) account ? (account.lead as JiraTempoUser).applicationUser.name : null