# Set Team field to default value

**URL:** <https://community.exalate.com/t/set-team-field-to-default-value/4866>\
**Category:** General Questions\
**Tags:** exalate, jiraserver, feature-customfield, jira-server, migrated\_question\
**Created:** [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/set-team-field-to-default-value/4866 "2024-11-04T07:28:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/set-team-field-to-default-value/4866/1 "2024-11-04T07:28:31Z")

</div>

_Originally asked by Michal Sitkey on 23 September 2021 [(original question)](https://oldcommunity.exalate.com/questions/37552654)_

* * *

Hi,

We have Jira to Jira connection where we are facing errors when issue is created where is validator set to Team field must be populated.

We need to set Team field to Default value.

This is not working for us :

issue.customFields.“Team”.value = “Team Name”

As we dont know what type is Team field can Exalate help us with code to set Team field a default value to not faced errors?

Thanks for help

* * *

#### Comments:

> **Serhiy Onyshchenko commented on 30 September 2021**
>
> > Hello, Michal Sitkey .  
> > Is this for Jira on-premise or Jira Cloud?

> **Michal Sitkey commented on 30 September 2021**
>
> > Jira is server version (no Cloud)

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/set-team-field-to-default-value/4866/2 "2024-11-04T07:28:32Z")

</div>

_Answer by Daniel Carvajal on 29 April 2022_

We have finally tested and implemented the following snippet to be used in the Incoming script:

```auto
def setTeamField = {
    String targetTeam ->
    
    
    def var = replica.customFields."Team"?.value?.description?.shareable?.asBoolean
    def pluginAccessor = com.atlassian.jira.component.ComponentAccessor.getPluginAccessor()
    def teamsPlugin = pluginAccessor.getEnabledPlugin("com.atlassian.teams")
    if (teamsPlugin == null) {
        //no teams plugin
        return
    }
    
    
    def teamsCl = teamsPlugin.classLoader
    def teamsCa = teamsPlugin.containerAccessor
    def tservClass = teamsCl.loadClass("com.atlassian.rm.teams.api.team.FullEnrichedTeamService")
    def _DefaultTeamDescription = teamsCl.loadClass("com.atlassian.rm.teams.api.team.data.DefaultTeamDescription")
    def _Optional = teamsCl.loadClass("com.google.common.base.Optional")
    def tserv = teamsCa.getBeansOfType(tservClass).first()
    def teamIds = tserv.getTeamIdsWithoutPermissionCheck()
    def teams = tserv.getTeams(teamIds)
    
    def team = teams.find { t -> t.description.title == targetTeam } //?: createTeam()
    //debug.error("this is the result of the team field: ${team}")
    
    
    issue."Team" = team
}
def targetTeam = replica.customFields."Team"?.value?.description?.title?.asString ?: "Team3" //change for default team to be set if no team field value is sent from the remote side 

if(firstSync && replica.project.key == "KANS"){
   issue.projectKey = "KAN"
   issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
  
   setTeamField(targetTeam) //Method to be called to set the field
}

```

The field can be sent in the outgoing script like this:

```auto
replica.customFields."Team" = issue.customFields."Team"

```

* * *

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 4, 2024, 7:28am UTC](https://community.exalate.com/t/set-team-field-to-default-value/4866/3 "2024-11-04T07:28:33Z")

</div>

_Answer by Jose Lobo on 23 September 2021_

Hey Michal Sitkey ,

Which doc were you referring to when writing this script?

This doc might help you \> [How to Set Default Values in a Custom Field](https://docs.idalko.com/exalate/display/ED/How+to+Synchronize+Custom+Fields#HowtoSynchronizeCustomFields-HowtoSetDefaultValuesinaCustomField).

* * *

#### Comments:

> **Michal Sitkey commented on 23 September 2021**
>
> > Team field is from Jira Roadmaps plugin.

> **Michal Sitkey commented on 24 September 2021**
>
> > Yes im trying with this, but Team field is specific from Jira Roadmaps and also type of this field is Team field type in custom fields. Than i dont know what to choose and how to set default value for this field.

> **Jose Lobo commented on 24 September 2021**
>
> > What type of field is it? (free text, select list, radio button, checkbox)

> **Michal Sitkey commented on 27 September 2021**
>
> > Its reason why im writing this question. Team field is from Jira Roadmaps addon and in custom fields tab have custom field type TEAM …Nothing from these what you write.

> **Francis Martens (Exalate) commented on 13 March 2022**
>
> > Hi Michal Sitkey
> 
> So - what you need is a way to know what the default value is for the team name?

> **Michal Sitkey commented on 14 March 2022**
>
> > No we need to team field a default value from connector inside of Exalate to overcome validator what is checking if team is presented inside of Issue. Than team must be set in process of creating of issue.

> **Michal Sitkey commented on 14 March 2022**
>
> > set a team field a default value

---

<div class="post-metadata">

**Author:** ![xl8bot](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/xl8bot/32/324_2.png) [@xl8bot](https://community.exalate.com/u/xl8bot)\
**Post date:** [November 6, 2024, 7:29am UTC](https://community.exalate.com/t/set-team-field-to-default-value/4866/4 "2024-11-06T07:29:28Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
