How to update the worknote of a change request from one ServiceNow to another ServiceNow instance?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi All,
I want to update worknote of a change request from one ServiceNow to another ServiceNow instance?
ServiceNow instance 1 is creating change request in ServiceNow instance 2 and now ServiceNow instance 2 wants to send some acknowledgement as ticket number in the worknotes to ServiceNow system 1.
For that I have created a Rest message:
I have created an after/update BR:
Code:
(function executeRule(current, previous /*null when async*/) {
var body = {};
var request = '';
var url = "";
var cor = current.getValue("correlation_id");
gs.log('CorrelationID' + cor);
if (current.work_notes.changes())
var comment = current.work_notes.getJournalEntry(1);
body = {
"work_notes": current.getValue('number')
};
request = 'Update comment';
try {
var req = new sn_ws.RESTMessageV2('Acknowledge AXON ticket', request);
req.setStringParameterNoEscape('sys_id', current.getValue("sys_id"));
//req.setEndpoint(url);
req.setRequestBody(JSON.stringify(body));
req.setAuthentication('basic', 'Axon API');
var reqInt = req.execute();
var requestBody = reqInt.getRequestBody();
var responseBody = reqInt.getBody();
var json = JSON.parse(responseBody);
var httpStatus = reqInt.getStatusCode();
gs.log('success response2:' + responseBody);
gs.log("Response status code is2 " + httpStatus);
} catch (ex) {
var message = ex.message;
gs.log('success response3:' + responseBody);
gs.log("Response status code is3 " + httpStatus);
}
})(current, previous);
I am getting below error:
success response2:{"error":{"message":"Standard Change Request not found","detail":""},"status":"failure"}
I am not able to pass the sys_id of the change request from ServiceNow instance 1.
Please help!
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @User205031,
if you have two different instances - then the sys ID will not be the same...
———
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */