Jira Update Added a locked field called Team

Todd Winton June 25, 2021

Recently updated to jira v8.16.1.  This install added a field called Team that is locked.  We also use tempo that has field called Team.  We also use scriptrunner that we use to set the Tempo Team field.  The Tempo Team field is a specialized custom field that is an object.  The update to jira broke this script

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.ModifiedValue
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

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()
def FieldManager = ComponentAccessor.getCustomFieldManager()
def indexManager = ComponentAccessor.getComponent(IssueIndexingService)


def teamField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find { it.name == "Team" }
if (!teamField) return;

def team = issue.getCustomFieldValue(teamField)

def newteam = teamService.getTeamByName("Engineering").getReturnedValue()
issue.setCustomFieldValue(teamField, newteam)
issue.setCustomFieldValue(df, 'ServiceDesk')

The line I believe is creating the issue is:

def teamField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find { it.name == "Team" }

I have been try a number of things and cannot get it to work.  EX (just the changed section)



def cFManager = ComponentAccessor.getCustomFieldManager()
def teamField = cFManager.getCustomFieldObject(customField_10906)
def teamFieldValue = issue.getCustomFieldValue(teamField)


def team = issue.getCustomFieldValue(teamField)

def newteam = teamService.getTeamByName("Engineering").getReturnedValue()
issue.setCustomFieldValue(teamFieldValue, newteam)

 However this is giving me errors related to references of an object:

Error5.png

Thanks

2 answers

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 25, 2021

What you want is 

def teamField = cFManager.getCustomFieldObject(10906)

or

def teamField = cFManager.getCustomFieldObject('customField_10906')

 or

def teamField = cFManager.getCustomFieldObjects(issue).find { it.name == "Team" && it.customFieldType.name.contains('Tempo')}
0 votes
Alexander Eck [Tempo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2021

Hi @Todd Winton

I believe the problem is the upgrade to a Tempo version that is breaking your script. You should look into this article where you probably find a solution https://tempo-io.atlassian.net/wiki/spaces/KB/pages/1682080365/Tempo+Team+custom+field

BR

Todd Winton June 25, 2021

That is where I got the basis for the original script.

Alexander Eck [Tempo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2021

So the script was running before the update of Jira? What version of Tempo are you using now?

Can you make check on the Tempo Team customfield name?

Tempo_Teams_Configuration.jpg

BR

Todd Winton June 25, 2021

Yes it did work prior to the update to Jira.  11.6.0 tempo version.  I forgot I can change the name of the tempo team field.  That might be the way to go.

Suggest an answer

Log in or Sign up to answer