1
0
-1

Context:


  1. Synchronisation Jira on-premise A to Jira on-premise B.
  2. On A side Single choice Database Picker cf "AssigneeJIRASW" is connected to side's B users DataBase.
  3. During the synchronisation, the value from cf "AssigneeJIRASW" of side A need to fill-in the value of "Assignee" field on the destination B side.


Problem:

  • Single choice Database Picker return a Json String value instead of a simple String


Solutions:


Without JIRA API imports:

/* firtssyncs and other fields syncs */

// CF "AssigneeJIRASW" to target "Assignee" field
String AssigneeJIRASW = replica.customFields."AssigneeJIRASW".value?.getAsString()

def defaultUser = nodeHelper.getUserByEmail("default.user@idalko.com")
if (AssigneeJIRASW) {
    issue.assignee = nodeHelper.getUserByEmail(AssigneeJIRASW) 
} else {
    issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
}
issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser

With JIRA API imports:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager

/* firtssyncs and other fields syncs */

// CF "AssigneeJIRASW" to target "Assignee" field
def issueSR = ComponentLocator.getComponent(IssueManager).getIssueObject(replica.key)
def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("AssigneeJIRASW")
def cFieldValue = issueSR.getCustomFieldValue(cField)

def defaultUser = nodeHelper.getUserByEmail("default.user@idalko.com")
if(cFieldValue) {
    issue.assignee = nodeHelper.getUserByEmail(cFieldValue)
} else {
    issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
}
issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser



    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Single choice Database Picker cf "AssigneeJIRASW" custom field configuration:

        CommentAdd your comment...