- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 03:40 AM
Third party User need to update the RITM(requested item) to service now instance using scripted web service.How i can achive this please help me out.
Example : suppose he want to update comment field so for that he will provide ritm number as a input. Based on the number need to get the field details from user and need to update to coresponding RITM.How can achive this please help me out.
Thanks
Prakash Ranjan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 03:59 AM
Hi,
You need to Navigate to Scripted Rest Api's module and define a new Service say as Update RITM and fill in the Scripted Rest form. Once you save the form you need to define the Resources where you can define the required HTTP method say you can use "PUT" in your scenario to update and write a script as below:
Script:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var remote_number = request.u_number1; Number coming as input from Source Application
//gs.log('Remote Number is' + remote_number);
var gr = new GlideRecord('sc_req_item');
gr.addQuery('u_rest_request', remote_number);
gr.query();
if(gr.next()) {
gr.short_description = request.short_description;
gr.update();
return {'Status' : 'The Request created is:' + gr.u_rest_request};
}
else{
return {'Status' : 'The request is not created'};
}
})(request, response);
Hope this helps.mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 01:37 AM
Hi Prakash,
Were you able to test the Integration. If your query is resolved please mark the answer as correct and close this thread.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 06:13 AM
Hi shloke04,
I just want to know if you have any idea how can I update an incident ticket from ServiceNow to another Third party platfrom a non-servicenow system.
I successfully created a POST method in REST Message and I also created a Business rule. I tick the Insert and Update checkbox on the Business Rule, Unfortunately everytime that I'm going to update the ticket, it is creating new ticket to the third party platform and when I'm going to add Work Notes or Additional Comments... It is not capturing.
What I want is to update the ticket from ServiceNow without creating a new one on the Third party platform and If I added a work notes or additional comments, it should be captured on the third party platform
Here is my Business Rule for POST
(function executeRule(current, previous /*null when async*/) {
try {
gs.log("SN - Sample TEST API");
var r = new sn_ws.RESTMessageV2('Optanix Incident Management', 'Optanix - Incident POST');
r.setStringParameterNoEscape('priority', current.priority );
r.setStringParameterNoEscape('comments', current.comments);
r.setStringParameterNoEscape('work_notes', current.work_notes);
r.setStringParameterNoEscape('category', current.category);
r.setStringParameterNoEscape('caller_id', current.caller_id);
// note that this isn't listed in REST content or variables.
r.setStringParameterNoEscape('description', current.description);
r.setStringParameterNoEscape('number', "number: " + current.number + ", sys_id: " + current.sys_id);
r.setStringParameterNoEscape('impact', current.impact);
r.setStringParameterNoEscape('short_description', current.short_description);
r.setStringParameterNoEscape('incident_state', current.incident_state);
r.setStringParameterNoEscape('correlation_id', current.correlation_id);
//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);
Your help is much appreciated, Thanks!