How to set Tempo account on Jira Server

Originally asked by Juan Grases on 23 June 2020 (original question)



Answer by Juan Grases on 23 June 2020

From the incoming processor, is it possible to get the Tempo Java API to get an account and assigning to a custom field:

import com.atlassian.jira.component.ComponentAccessor

def exaPlugin = ComponentAccessor.pluginAccessor.getEnabledPlugin("com.tempoplugin.tempo-accounts")
def exaCl = exaPlugin.getClassLoader()
def essClass = exaCl.loadClass("com.tempoplugin.accounts.account.api.AccountService")
def ess = ComponentAccessor.getOSGiComponentInstanceOfType(essClass)

def projectId = issue.project?.id ?: nodeHelper.getProject(issue.projectKey).id

def allAccountsForProject = ess.getAccountsByProject(projectId).get()

//Other methods: getAccounts(boolean), getAccountId(java.lang.String), getAllAccounts(), getAccountById(int), getAccountByIds(java.util.Set).

//This is an example where the field is set from a default CF
//String accountName = replica.customFields."Account".value

String accountName = "The Account"


issue.customFields."Account".value = allAccountsForProject.find{acc -> acc.name == accountName}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.