Bi-directional Incident Integration Between Two ServiceNow Instances – Step-by-Step Guide

HasanRaja
Tera Expert

Step 1: Create a User in Instance 1

  1. Navigate to User Administration > Users and create a new user (e.g., User ID: harshil) with a secure password.

  2. Enable the "Web service access only" checkbox. This restricts the user from logging into the instance via the UI and allows access only via web services.

  3. Assign the roles: itil and web_service_admin to this user.

Step 2: Configure a REST Message in Instance 2

  1. To send outbound REST requests from Instance 2 to Instance 1, you need to configure a REST Message.

  2. Navigate to: System Web Services > Outbound > REST Message

  3. Click New, provide a name (e.g., Instance-2 RM) and define the Endpoint.

  4. Set the Authentication Type to Basic and create a new Basic Auth Profile with:

    • Name: Your preferred name

    • Username: harshil (Instance 1 user)

    • Password: Same password used in Instance 1

HasanRaja_1-1750239208131.png

 

      5. Submit the REST Message. You'll now see a default GET method under the HTTP Methods related list.

HasanRaja_0-1750239116002.png

 

Step 3: Create a New POST Method

  1. Scroll to the HTTP Methods related list and click New.

  2. Name it POST, set the HTTP Method to POST, and Save the record.

  3. Click Preview Script Usage Related Link and copy the generated script for use in the Business Rule.

Step 4: Create a Business Rule in Instance 2

  1. Navigate to System Definition > Business Rules and create a new Business Rule.

    • Name: Create tasks in Ins-1

    • Table: Incident

    • Check Advanced and select After Insert

  2. Go to the Advanced tab and paste the script you copied from the POST method.

  3. Remove any unnecessary comments from the script.

  4. Create a body object to define the fields you want to send. For example, to send short_description and caller_id:

 var body = {
 "short_description":current.getDisplayValue('short_description'),
 "caller_id":current.getDisplayValue('caller_id')
 };
     5. Covert the body object into JSON String by using this code
 r.setRequestBody(JSON.stringify(body));
     6. If you want, you can print the Request status by using this code 
 gs.addInfoMessage("httpStatus is: "+httpStatus);
     7. You can use the complete script provided below. Ensure that the correct REST Message name and POST method are specified.
 
(function executeRule(current, previous /*null when async*/) {
 
try {
var r = new sn_ws.RESTMessageV2('Instance-2 RM', 'POST');
 
var body = {
"short_description":current.getDisplayValue('short_description'),
"caller_id":current.getDisplayValue('caller_id')
};

r.setRequestBody(JSON.stringify(body));

var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();

gs.addInfoMessage("httpStatus is: "+httpStatus);
}
catch(ex) {
var message = ex.message;
}

})(current, previous);
 

Testing the Integration

Now, try creating a new incident in Instance 2. It should automatically create a corresponding incident in Instance 1 with the same values(Short description and Caller).

 

With half of the process complete, repeat the same four steps, but this time switch the roles of the instances

 

Step 1: Create a User in Instance 2

  1. Navigate to User Administration > Users and create a new user (e.g., User ID: hasan) with a secure password.

  2. Enable the "Web service access only" checkbox. This restricts the user from logging into the instance via the UI and allows access only via web services.

  3. Assign the roles: itil and web_service_admin to this user.

Step 2: Configure a REST Message in Instance 1

  1. To send outbound REST requests from Instance 1 to Instance 2, you need to configure a REST Message.

  2. Navigate to: System Web Services > Outbound > REST Message

  3. Click New, provide a name (e.g., Instance-1 RM) and define the Endpoint.

  4. Set the Authentication Type to Basic and create a new Basic Auth Profile with:

    • Name: Your preferred name

    • Username: hasan (Instance 2 user)

    • Password: Same password used in Instance 2

  5.  Submit the REST Message. You'll now see a default GET method under the HTTP Methods related list.

Step 3: Create a New POST Method

  1. Scroll to the HTTP Methods related list and click New.

  2. Name it POST, set the HTTP Method to POST, and Save the record.

  3. Click Preview Script Usage Related Link and copy the generated script for use in the Business Rule.

Step 4: Create a Business Rule in Instance 1

  1. Navigate to System Definition > Business Rules and create a new Business Rule.

    • Name: Create tasks in Ins-2

    • Table: Incident

    • Check Advanced and select After Insert

  2. Go to the Advanced tab and paste the script you copied from the POST method.

  3. Remove any unnecessary comments from the script.

  4. Create a body object to define the fields you want to send. For example, to send short_description and caller_id:

var body = {
 "short_description":current.getDisplayValue('short_description'),
 "caller_id":current.getDisplayValue('caller_id')
 };
     5. Covert the body object into JSON String by using this code
 r.setRequestBody(JSON.stringify(body));
     6. If you want, you can print the Request status by using this code 
 gs.addInfoMessage("httpStatus is: "+httpStatus);
     7. You can use the complete script provided below. Ensure that the correct REST Message name and POST method are specified.
 
(function executeRule(current, previous /*null when async*/) {
 
try {
var r = new sn_ws.RESTMessageV2('Instance-1 RM', 'POST');
 
var body = {
"short_description":current.getDisplayValue('short_description'),
"caller_id":current.getDisplayValue('caller_id')
};

r.setRequestBody(JSON.stringify(body));

var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();

gs.addInfoMessage("httpStatus is: "+httpStatus);
}
catch(ex) {
var message = ex.message;
}

})(current, previous);
 

Testing the Integration

Now, test the setup by creating an incident in either instance. You’ll notice that a corresponding incident is created in the other instance as expected. However, this may result in a problem—incidents will continue to be created in a loop between the two instances.
 
To prevent this infinite loop, you need to add a method in condition field to both Business Rules using the following method:
gs.isInteractive(); 
 
This ensures the Business Rule only runs when the record is created manually through the UI and not by an integration or script.
1 REPLY 1

JavierPM
Tera Contributor

Hi! I'm the community manager at Exalate.

Great breakdown — this is a solid guide for setting up manual bi-directional integration between two ServiceNow instances using REST messages and business rules. Very helpful for teams who need full control and don’t mind working with scripts.

If you're ever looking to streamline this setup or avoid maintaining custom scripts long-term, there are tools that handle this out of the box. For example, Exalate supports bi-directional synchronization between ServiceNow instances, with the ability to customize which fields are synced, without running into infinite loop issues.

Each approach has its place depending on your goals, but thought it might be helpful to mention if anyone’s exploring other options.