- 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
‎04-03-2017 05:17 AM
Hi,
Can you copy the below Script and check if it's allowing you to save the BR or not.
(function executeRule(current, previous /*null when async*/) {
try {
var r = new sn_ws.RESTMessageV2('TestandDevInt_rest', 'TestandDevInt_rest');
r.setStringParameterNoEscape('u_priority', current.priority);
r.setStringParameterNoEscape('u_caller_id', current.caller_id);
r.setStringParameterNoEscape('u_number', current.number);
r.setStringParameterNoEscape('u_category', current.category);
r.setStringParameterNoEscape('u_short_description', current.short_description);
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthentication(authentication type, profile name);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('Status is: ' + status + 'Response is: ' + responseBody);
}
catch(ex) {
var message = ex.getMessage();
}
})(current, previous);
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
‎04-03-2017 05:19 AM
Nope. Same thing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 05:29 AM
Strange. If you are suing a personal instance, can you share the URL and Credentials, I can try from my end.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 05:33 AM
Hi, Thanks
No its not a personal instance.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2017 05:36 AM
function onAfter(current, previous /*null when async*/)
I have applied it as above and it has accepted the script.