- 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-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-15-2017 04:33 AM
Thanks !!! Shloke.I will tried with this and update you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 04:45 AM
HI Shloke,
Thanks for you reply.can you please guide me how can i test this.Currently i am using postman chrome default tool to test the web service.Thanks in advance.
u_number1 what i can use for testing..
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 04:12 AM