How to update the ServiceNow RITM worknotes and state values through Scripted REST API POST ?

ITSM ServiceNow
Kilo Explorer

Requirement:
We have a service catalog form and it has one list collector field with 20 values.

Whenever user submits this catalog form via service catalog portal it should hit the third party application with those 20 values.

Based on the request received, the third party application should process those 20 values and sends( may be after 2 hours) the response back to ServiceNow to update the particular RITM worknotes and state as well based on the response received from third party application.

-----------------------------------------------------------------------------------------------------------------------------------------------

I did the below to achieve the above requirement:

We have a service catalog form and it has one list collector field with 20 values.

--> For this, I have created ServiceCatalog form.

 

Whenever user submits this catalog form via service catalog portal it should hit the third party application with those 20 values.
--> For this, I am calling third party REST API from the catalog form workflow "run script" activity for sending 20 values to third party application.


Based on the request received, the third party application should process those 20 values and sends( may be after 2 hours) the response back to ServiceNow to update the particular RITM worknotes and state as well based on the response received from third party application.
--> For this, I have created Scripted REST API POST to receive the response from Third party application.

Now the question is below:

I want to know how to update the ServiceNow RITM worknotes and state values based on the response received from third party application through ServiceNow Scripted REST API POST method.

What is the best method to do this without impacting the ServiceNow platform ?

9 REPLIES 9

Tony Chatfield1
Kilo Patron
Hi, you can either update the record directly via rest or populate the rest content into a temp import table and then use a transform map/script to update your table. this would be my preferred option as the transform gives you complete control of your update. Have a look at posts for scripted rest API as while it is not necessary make the end to end process much easier to manage.

Hi Tony,

Thanks a lot for your response.

We are not receiving any RITM info from third party application into Scripted REST API POST resource. We have to update the RITM based on the run script of the workflow that we have submitted from service catalog portal workflow run script.

My plan is to compare the RITM message worknotes that we have vs received through Scripted REST post.

 

Will that impact ServiceNow platform performance ? Please help on this.

 

Thanks in advance!

Hitoshi Ozawa
Giga Sage
Giga Sage

You'll need to update the sc_req_item table. Following will add 1 work note. You'll need to change to update for 

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
if(request.queryParams.number && request.queryParams.number.trim()){
  var gr = new GlideRecord('sc_req_item');
  gr.addQuery('sys_id',request.queryParams.number);
  gr.query();
  if(gr.next()){
    gr.work_notes = request.queryParams.work_notes;
    gr.update();
  }
}
})(request, response);

Hitoshi Ozawa
Giga Sage
Giga Sage

Import set is a batch operation. It's good if there are many records to be imported/exported all at once.

REST API is a real-time solution. It will slow down the system if there are many records to be processed.