1
0
-1

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

  1. Serhiy Onyshchenko

    Hello, Michal Sitkey .
    Is this for Jira on-premise or Jira Cloud?

  2. Michal Sitkey

    Jira is server version (no Cloud)

CommentAdd your comment...

2 answers

  1.  
    3
    2
    1

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

    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:

    replica.customFields."Team" = issue.customFields."Team"
      CommentAdd your comment...
    1.  
      1
      0
      -1

      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.

      1. Michal Sitkey

        Team field is from Jira Roadmaps plugin.

      2. Michal Sitkey

        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.

      3. Jose Lobo

        What type of field is it? (free text, select list, radio button, checkbox)

      4. Michal Sitkey

        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.

      5. Francis Martens (Exalate)

        Hi Michal Sitkey 

        So - what you need is a way to know what the default value is for the team name?


      6. Michal Sitkey

        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.

      7. Michal Sitkey

        set a team field a default value

      CommentAdd your comment...