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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2020 02:19 PM
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 ?
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2020 05:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2020 01:01 AM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2020 05:40 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2020 01:45 AM
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.