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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Portfolio for Jira "Team" Field?


I have a Portfolio for Jira Team field and I am trying to set it's value using a script runner script. 


def PTFValue = issue.getCustomFieldValue(portfolioTeamField)

As you can see, I can log the "value", "title" and "description" but when I try to pass the "value" of 5 into a setCustomFieldValue method I get a type cast error.

How do I access all of the options for that field and assign them to unique variables? They are not simply strings, as the logs show. Even though the "title" of that Team object is Profiles I cannot pass the string Profiles as a value for that field.  The "Description" value (calling PTFValue.getDescription()) appears to change when logged at different run times. 


2020-05-13 14:31:58,687 DEBUG [runner.AbstractScriptRunner]: PTFValue =5
2020-05-13 14:31:58,687 DEBUG [runner.AbstractScriptRunner]: PTFValue Title = Profiles
2020-05-13 14:31:58,687 DEBUG [runner.AbstractScriptRunner]: PTFValue Description =  

I need to assign the Team field's value but I cannot use a string or number. I want to access all of the Team field's options but I am unable to do so. 

Is there some trick to access Portfolio For Jira fields? Any documentation that may help? 


Thank you! 

4 answers

1 accepted

2 votes
Answer accepted

In order to set the Team field, we will need to provide a value whose type is We can get one of these by using the GeneralTeamService:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin

import com.onresolve.scriptrunner.runner.customisers.PluginModule



@PluginModule GeneralTeamService teamService 

def team = teamService.getTeam(123).get()

where 123 is the numerical ID of the team. If you need a complete list of IDs for all your teams, for reference purposes, then you can run the following in the Script Console:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin

import com.onresolve.scriptrunner.runner.customisers.PluginModule

import @WithPlugin("com.atlassian.teams")

@PluginModule GeneralTeamService teamService 

teamService.teamIdsWithoutPermissionCheck.collectEntries {[(it) :teamService.getTeam(it).get()?.description?.title]}

which will show you the ID and name of every team.

Hello Judeboy, 
I'm trying to run your code to get a complete list of IDs for all my teams and I'm running into the following error after copying and pasting your code into the script console.


The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script36.groovy: 5: unexpected token: @ @ line 5, column 59. @WithPlugi ^ 1 error </pre>


2021-02-23 13:31:08,254 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2021-02-23 13:31:08,258 ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingPropertyException: No such property: teamService for class: Script34 at


Any ideas?

Do you have a syntax error? Possibly an @ somewhere? 

It looks like it is not loading the module you need to use "teamService" correctly

In @Judah s post of Jun 22, 2020, I verified both sets of code work.

Please visit How to set Portfolio Team field on an issue with ScriptRunner? to see an example to Edit/Set the Advanced Roadmaps Team field programatically.

OK, I cobbled this together with snippits from other posts, some sawdust and a generous use of the philosophy of 'even a blind squirrel can find a nut'.  This will find the team that matches the name you provide and then sets the Team field to that value.  It looks nice and clean insider a Scriptrunner Console, but its a blood bath if you load it up into an IDE (unless you can pull in the roadmaps API)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@PluginModule GeneralTeamService teamService

ApplicationUser user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

// useful for testing
//IssueManager issueManager = ComponentAccessor.issueManager
//String issueKey = 'ABC-477130'
//Issue issue = issueManager.getIssueObject(issueKey)

Issue anIssue = issue
MutableIssue mIssue = ComponentAccessor.issueManager.getIssueObject(anIssue.key)

CustomField teamCF = ComponentAccessor.customFieldManager.getCustomFieldObjects(anIssue).find { == "Team" }
DefaultTeam existingTeamObject = anIssue.getCustomFieldValue(teamCF ) as DefaultTeam
DefaultTeam newTeamObject = findTeambyName("Agile Tools")

if (existingTeamObject != newTeamObject) {
mIssue.setCustomFieldValue(teamCF ,newTeamObject)
ComponentAccessor.issueManager.updateIssue(user, mIssue, EventDispatchOption.DO_NOT_DISPATCH, false)

DefaultTeam findTeambyName(String teamName) {
@PluginModule GeneralTeamService teamService
Long rmTeamId = teamService.teamIdsWithoutPermissionCheck.find {teamService.getTeam(it,false).get()?.description?.title?.toLowerCase() == teamName.toLowerCase()}
Team rmTeamObject = teamService.getTeam(rmTeamId,false).get()
return rmTeamObject as DefaultTeam
// FYI, not using scriptrunner, but
// Using JMWE postfunction I can set Team to it's string id.  For example,
// if I want to set Team to "App Operations Support", I can do:

//  tm= issue.get ("Team")   // do this for an existing issue with the Team value you want.
// ("tm is $tm")
// shows me that "App Operations Support" is 6

return "6"

Suggest an answer

Log in or Sign up to answer