Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Update Added a locked field called Team

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

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

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

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

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.

0 votes

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')}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.16.1
TAGS
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

129 views 1 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you