How jira and exalate sync

Originally asked by redjeb on 30 November 2020 (original question)


Hello,

We have a customer who created a Jira issue from servicenow with their own rest api call (not with exalate) , they want the Jira issue to be synchronised with the snow ticket, how can we achieve this ?

Which field is used to achieve the sync?

Best regards


Answer by Francis Martens (Exalate) on 30 November 2020

What you will have to do is

a) Create a connection between ServiceNow and Jira

b) Create the logic to connect the ServiceNow entity with the Jira issue
This can be done manually or via automation.

Via automation - example but YMMV

Incoming Sync - Jira OnPrem - untested

import com.atlassian.jira.component.ComponentAccessor

// replica.customKeys.TargetIssueKey is set on the other side with the target issue key ...


if (firstSync) {
   def targetIssueKey = replica.customKeys.TargetIssueKey
   // if the targetIssueKey is provided, connect with existing issue
   if (targetIssueKey) {
	   // look up the issue id (assuming you always get a hit which is of course utterly naive.

	   def jIssue = ComponentAccessor.getIssueManager().getIssueObject(targetIssueKey)
	   issue.id = jIssue.id
	   issue.key = targetIssueKey
   } else {
	   issue.summary = "..."
   }



}

Once that the issue is connected, any change will be synced