How to Sync Multiple Entities on ServiceNow

    This article shows how to synchronize different entities on ServiceNow.

    Introduction

    Exalate allows to synchronize the following entities on ServiceNow:

    • incident
    • customerCase from Case Management module
    • problem
    • changeRequest from Change Management module

    You can add sync rules for every entity type separately.

    Check the reference of supported fields and entities that you can synchronize from ServiceNow instance.

    Configuration

    To synchronize multiple entity types you need to adapt the sync rules using if blocks. This helps Exalate to distinguish sync rules for different entity types. Check the examples below.

    Source side

    Outgoing sync

    To send incidents and customerCases use the code below: 

    if(entityType == "incident") {
      replica.issueTypeName = "Task"    
      replica.summary = incident.short_description
      replica.description = incident.description
      replica.comments = incident.comments
    	///other fields supported by the incident entity
    }
    if(entityType == "customerCase") {
        replica.summary = customerCase.short_description
        replica.description = customerCase.description
        replica.comments = customerCase.comments
        replica.attachments = customerCase.attachments
    	///other fields supported by the customer case entity
    }

    If you want to send problem add this code to the new line in the end of existing outgoing sync rules:

    if(entityType == "problem") {
      replica.summary = problem.short_description
      replica.description = problem.description
      replica.comments = problem.comments
      replica.attachments = problem.attachments
    	///other fields supported by the problem entity
    }

    If you want to send changeRequests add this code to the new line in the end of existing outgoing sync rules:

    if(entityType == "changeRequest") {
      replica.summary = changeRequest.short_description
      replica.description = changeRequest.description
      replica.comments = changeRequest.comments
      replica.attachments = changeRequest.attachments
    	///other fields supported by the Change request entity
    }

    Destination side ServiceNow

    You need to map the incoming entities. For example:

    • Jira issue of type bug to the ServiceNow incident
    • Jira issue of type improvement to the ServiceNow change request

    Below you can find some examples of mapping multiple issue types from Jira to different entities on ServiceNow.

    Incoming sync

    If you want to sync multiple entities in one connection add the following code at the beginning of your Incoming sync rules:

    def defaultEntityType = 'customerCase' //Please change the defaultEntityType to 'incident' to create incidents by default
    if(firstSync) entityType = defaultEntityType else entityType

    To create incidents with the received information on your side add the code below:

    if(replica.issueTypeName == "Bug") { //if the received issue typeName is Bug create Incident on ServiceNow
        if(firstSync) {
            incident.correlation_id = replica.key
            incident.correlation_display = replica.key   
        }
        incident.short_description = replica.summary
        incident.description = replica.description
        incident.comments += replica.addedComments
    }

    To create problems with the received information on your side add the code below:

    if(replica.issueTypeName == "Problem") { //if the received issue typeName is Problem create Problem on ServiceNow
        if(firstSync) {
            problem.correlation_id = replica.key
            problem.correlation_display = replica.key   
        }
        problem.short_description = replica.summary
        problem.description = replica.description
        problem.comments += replica.addedComments
    }

    To create changeRequests with the received information on your side add the code below:

    if(replica.issueTypeName == "Improvement") { // if the received issue typeName is Improvement create Change on ServiceNow
        if(firstSync) {
            changeRequest.correlation_id = replica.key
            changeRequest.correlation_display = replica.key   
        }
        changeRequest.short_description = replica.summary
        changeRequest.description = replica.description
        changeRequest.comments += replica.addedComments
    }

    To create customerCases with the received information on your side add the code below:

    if(replica.issueTypeName == "Support Case") { // if the received issue typeName is Support Case create Customer Case on ServiceNow
        if(firstSync) {
            customerCase.correlation_id = replica.key
            customerCase.correlation_display = replica.key   
        }
        customerCase.short_description = replica.summary
        customerCase.description = replica.description
        customerCase.comments += replica.addedComments
    }

    To start the synchronization create a trigger for every entity type separately.

    Have more questions? Ask the community