Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the team custom field of an issue with a Behaviour script

Antoine Roy-Lachance July 20, 2022

Hi!

I'm trying to set the Team custom field value to the current team value of a context issue in a Behaviour script but the value is never set. I'm able to get the id and the title of the team of the context issue but when I'm using the setFormValue function on the Team custom field the Team value is never set. I've also tried the setting defaults for selects from the Scriptrunner docs but when I'm trying to get the options of the Team custom field it always returns an empty array (the link to the Scriptrunner doc: https://scriptrunner.adaptavist.com/5.5.5/jira/recipes/behaviours/setting-default-fields.html )

Here's a snippet of my code

image.png

1 answer

0 votes
Antoine Berry
Community Champion
July 20, 2022

Hello @Antoine Roy-Lachance ,

Is the team custom field of type Group ?

What is the "teamService" in the snippet ?

Antoine Roy-Lachance July 20, 2022

Hi Antoine,

The custom field is of type Team.

The team service is from a plugin of atlassian, I need it to get the team value

here's how I include it in my script:

@WithPlugin("com.atlassian.teams")
@PluginModule GeneralTeamService teamService

Antoine Berry
Community Champion
July 22, 2022

Hi Antoine,

I do not know about this plugin (and cannot find it). Could you please link its marketplace page ?

Behaviours usually uses the object Id or String to set the field value. If that does not work, maybe the teams plugins is not supported for this scripting.

Antoine Roy-Lachance July 25, 2022

I don't think it's marketplace plugin. It's based on the Team REST API from atlassian from what I understand. For my other issue fields I use thee getFieldById method to get the context issue field and then use the setFormValue to set the context issue field to the value of my issue but the Team custom field seems to work differently. I've tried to set the value of the Team custom field with it's team id and it's title but it didn't work.

Here's how I import the plugin for the teams in my script

image.png

 

To get the current team value, I use this function from the teamService with the teamId as the parameter

teamService.getTeam(TeamIdAsInt).get()

Like Antoine Berry likes this

Suggest an answer

Log in or Sign up to answer