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.

Nana5
Mega Guru

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

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

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


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

21 REPLIES 21

Hi,



May I know what the setting under the Business Rule tab When to run and Action is? I have used the script above, but when I try to submit, I keep getting this error:



missing function declaration for onAfter.



The When to run setting is After, Insert and Update as suggested above.



Please help!


Hi,



Please find the screen shots below:



find_real_file.png



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi,



Thanks for the, yes That is what my set up is, but I have filted my own condition. I cant save it though. It keeps saying, Missing function declaration for onAfter. :S


Can you share the screen shot of the Business Rule you have configured.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Please see attached. script.PNG


whentorun.PNG