Snow To Snow Bidirectional Integration - DxSherpa
Snow To Snow Bidirectional Integration - DxSherpa
Snow To Snow Bidirectional Integration - DxSherpa
Using Integration Two Different or Same Platform /Tool / Application Can communicate with each
other, they can able to Post Data, Get Data, Update Data, Delete Data between them using REST HTTP
Methods
Bi-Direction Integration means both the App can able Performed Operations on each other; basically
we can say it’s a two way communication.
Uni-Direction Integration means only one app can able Performed Operations on another App; it’s a
One way communication.
Types of Integration
Outbound Integration :- ServiceNow can Performed CRUD Operation in Third Party Tool
Inbound Integration :- Third-party Tool can Performed CRUD Operation in ServiceNow
POST METHOD :- Both instance can able to POST data between each other
Steps:
You can create it by clicking on magnifier glass new-> give Name /Userid/Password of another instance
Click on New:-
If you get 201 as status means tested successfully and will get expected response.
Click on related link Preview Script Usage from HTTP Method page.
Preview Script Usage: – It is Automated created Script for our Outbound REST message, we can use this
Script in Business Rule for Connecting Current Instance to another instance,
If we use this Script in Business Rule then we don’t need to add [Endpoint/HtppMethod/Basic
Authentication/Http Headers] in Business Rule as Preview Script Usage contains all this Things.
https://dxsherpa.com/blogs/snow-to-snow-bidirectional-integration/ 3/6
7/6/22, 7:56 PM Snow to Snow Bidirectional Integration | DxSherpa
So as our Outbound REST Message is tested successfully then we can good to create Business Rule for
Posting Data through Current instance to another instance.
In Business Rule first we need to Store Payload body structure of another instance in variable so that
Data can map correctly.
Then we need to add Script which is taken from Outbound REST Message
Here our body structure is in JSON format so we need to convert it in String so ServiceNow can Read .
to do this we used [r.setRequestBody(JSON.stringify(body));]
Also the Response we are getting is in JSON Format so again we need to parse it var ParseData =
JSON.parse(response.getBody()); only if we need to perform operations on response [ie PUT]
try {
catch (ex) {
Create New record in Current Instance you will get same incident in another instance
https://dxsherpa.com/blogs/snow-to-snow-bidirectional-integration/ 4/6
7/6/22, 7:56 PM Snow to Snow Bidirectional Integration | DxSherpa
Getting Data from another instance [B] to current instance [A] we need to Set Inbound
Web Service
You need to Follow above Steps in Another instance so Instance B also able to Post Data in instance A
We just need to pass sys_id for Instance B to A why ? It will use in PUT method Just add “u_externalsys_id” :
current.getValue(‘sys_id’), in body Payload And Create 1 field in Incident Form of Instance A[Target instance]
“External_Sys_id” Type :- String, This field store sys_id of instance B[Source instance]
PUT METHOD: – Both instance can able to update data between each other [for
instance A to B]
For Processing PUT method first thing we need to keep in mind that we are Performing Updation on Single
Record so we need its sys_id to work on. So in Endpoint we are not mentioning sys_id as it will different for
every record, hence we are passing sys_id of particular record Dynamically in Business Rule.
For updating data you need to create PUT method in Outbound REST Message In instance A [Source
instance] , as we have already created Outbound REST Message for POST, so we just need to add PUT
method in HTTP Method.
B] Create 1 field in Incident Form “External_Sys_id” Type: – String, [ if you have not created in POST B to A ]
This field store sys_id of another instance record so we can add this sys_id in our Endpoint, so we can
modified that particular record
In Business Rule Script we need to fetch it and add it to Endpoint as we are passing sys_id dynamically var
Ex_sys = current.getValue(‘u_externalsys_id’);
C] Then we need to add Script which is taken from Outbound REST Message.
"short_description": current.short_description.toString(),
"urgency": current.urgency.toString(),
"caller_id": current.getDisplayValue('caller_id'),
"impact": current.getDisplayValue('impact'),
"state": current.getDisplayValue('state'),
"priority": current.getDisplayValue('priority'),
"subcategory": current.getDisplayValue('subcategory'),
"category": current.getDisplayValue('category'),
};
try {
var r = new sn_ws.RESTMessageV2('Snow-Bi', 'PUT');
r.setEndpoint('https://dev62522.service-now.com/api/now/table/incident/' +
Ex_sys);
r.setRequestBody(JSON.stringify(body));
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
})(current, previous);
Save
Now Create 2-3 Record in instance B[Tareget Instance] and Check in you Source instance You will get same
Record with External sys_id , so When you will updating Record in Instance A[Source Instance] it will Update
in Instance B, through sys_id
https://dxsherpa.com/blogs/snow-to-snow-bidirectional-integration/ 6/6