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
‎11-01-2020 10:59 PM
Hey
Hey How you able to achieve this
Req is Based on the response code success or failure we need to update the State of the RITM through scripted rest API ?
Any Idea ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 02:04 AM
Hi,
you should be able to update the state of RITM via scripted REST API
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 02:11 AM
Hello
I need to update the state if the response code is success then state should be close completed and workflow should end or if the response code is failure then state should be in-progress and create a manual task ,it is done based on the script you helped
var corrId = 'Correlation ID ';
var responseCode = 'Response Code';
var requestBody = request.body.dataString;
var parser = new JSONParser();
var parsedData = parser.parse(requestBody);
var ID= parsedData[corrId]; //We are parsing the correlation id and storing in the id field to query the Incident table
responseCode = parsedData[responseCode];
var gr = new GlideRecord('incident');
gr.addQuery('correlation_id', ID); // We are querying the incident table to match the correlation id in the Incident table and update the Work notes
gr.query(); // Found the correlation id in the Incident Table
if(gr.next()){
gr.work_notes = responseCode; // Update the Work notes with the response code
gr.update();
response.setStatus(200);
} else {
response.setStatus(404);
}
task ,it is done based on the script you helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 02:58 AM
Hi,
Would you mind creating a new question as this is quite older one.
Do tag me so that I can help
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 03:09 AM
Hello
https://community.servicenow.com/community?id=community_question&sys_id=ae517d20dbdca4104aa5d9d9689619b9