How to sync multiple entities ServiceNow to one Jira project?

Originally asked by Daniel Caloto on 24 June 2021 (original question)


We would like to know how to synchronize several ServiceNow entities in a Jira project, for example, Incident and Problem. Each of the entities would be assigned to an issue type, Incident would go to Bug and Problem would go to Task. How can we distinguish in the Jira incoming which entity is being synchronized? What ServiceNow value should be sent in the Outgoing?
Thank you very much
Best regards
D


Answer by Daniel Caloto on 24 June 2021

Could this be done by forcing the issuetype replica value for each of the entities in the servicenow outgoing?
if(entityType == “incident”) {
replica.issueTypeName = “Bug”
replica.summary = incident.short_description
replica.description = incident.description
replica.comments = incident.comments
///otros campos soportados por la entidad incidente
}
if(entityType == “customerCase”) {
replica.issueTypeName = “Case”
replica.summary = customerCase.short_description
replica.description = customerCase.description
replica.comments = customerCase.comments
replica.attachments = customerCase.attachments
///otros campos soportados por la entidad customer case
}
BR


Comments:

Francis Martens (Exalate) commented on 26 June 2021

Good suggestion.

On the incoming sync in Jira, you can then specify

if (firstSync) {
   issue.typeName = replica.issueTypeName

}

The only problem here, is that if you decide on the servicenow side what the target issuetype should be, you create a dependency between the two environments.

A similar approach is sending the entityType

ServiceNow - Outgoing

...
replica.sourceType = entityType
...

And in the incoming

Jira - Incoming

def typeMap = [
    "incident" : "Bug",
    "Problem" : "Task"
]

if (firstSync) {   

    // default to request if the incoming sourceType is not mapped correctly   
    issue.typeName = typeMap[replica.sourceType] ?: "Request"
}

Whenever the configuration changes on the Jira side, you can adapt it on the Jira side without requiring to access the servicenow side.