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! 

2 answers

1 accepted

1 vote
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

// 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

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