Update Incident - REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 04:00 PM
Using REST Message POST Method, I'm able to create an incident in another instance of ServiceNow using after-insert business rule. I need help with update of the incident i.e., if someone updates that incident from their end, I want it to be updated on my instance. I need help with the business rule script for the update of it. Please help me how to achieve this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 06:51 PM - edited ‎10-02-2023 06:55 PM
Hi you can use REST API explored like below to build the script
and
Here is the example. You need to create PUT method REST API.
// pass fields to update
var obj = {
"close_code": current.getValue('close_code'),
"close_notes": current.getValue('close_notes'),
"state": current.getValue('state')
};
var id = current.correlation_id; // sysid of incident of other instance
try {
var r = new sn_ws.RESTMessageV2('IncidentCreation', 'updateINC'); // Rest Message name and Put Method API name
r.setEndpoint("https://xxx.service-now.com/api/now/table/incident/" + id); // end point
r.setHttpMethod(PUT);
r.setRequestBody(JSON.stringify(obj));
var response = r.execute();
var responseBody = response.getBody();
gs.info("Request Body==>" + JSON.stringify(responseBody));
var httpStatus = response.getStatusCode();
gs.info("httpStatus==>" + httpStatus);
} catch (ex) {
var message = ex.message;
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 07:29 PM
Hello @Palacharla Gowt
Are you using a Scripted REST API or OOTB Table API.
You can use REST API Explorer to generate code samples for both Scripted REST or Table API and you can use that in your BR to trigger the transaction.
And preferably use Async Business Rule to improve User experience.
Please let me know if you need any more help on this.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 09:04 PM
Refer below links for step by step instructions on how to integrate 2 servicenow instances
ServiceNow to ServiceNow Integration using REST API and PUSH and PUT methods with Business Rule
You can also explore on Ebonding Spoke with less scripting
Refer the below link which has the approach with example shared by me.
Integration hub ebonding spoke
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader