ServiceNow to ServiceNow Integration using REST API and PUT method with Business Rule
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 06:03 AM - edited 09-19-2024 06:05 AM
In (BR), I am attempting to update an incident in Instance A so that it is dynamically updated in Instance B. However, the correlation_id field is empty in both instances. I tried assigning the number field from Instance A to the correlation_id field in Instance B, and i do not want to use sys_id , since they are unique in both instances , but the update did not work.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var incidentNumber = current.getDisplayValue('number');
try {
var r = new sn_ws.RESTMessageV2('Integration with dev278218', 'PUT a record');
r.setEndpoint('https://dev278218.service-now.com/api/now/table/incident/' +incidentNumber);
var body = {
"short_description": current.getDisplayValue('short_description'),
"caller_id": current.getDisplayValue('caller_id'),
"correlation_id": current.getDisplayValue('number')
};
r.setRequestBody(JSON.stringify(body));
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
})(current, previous);
0 REPLIES 0