- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 12:29 AM
Hi,
I have a requirement like, when user update state, Comments, Priority etc.. in third party application, then it should be updated in servicenow
I am using the scripted rest api PUT method to update the fields in servicenow.
Could you please help,
Script Include:
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 10:45 AM
Hi Harish,
As you said when ticket is updated in third party application then it should update the same in ServiceNow.
Are you saying that you have exposed the Scripted REST API to the third party.
I could see that you have used PUT method i.e. fine.
But the way you are fetching the response is incorrect . use following
var requestBody = request.body.dataString;
try to add logs to check requestBody is received correctly in your scripted rest api resource
also you are not sending the id as json key while consuming the REST endpoint so how you will get the value by parsing the json
the json parsing you have used is not correct. use following
var parser = new global.JSON();
var parsedData = parser.decode(requestBody);
var id = parsedData.work_notes;
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
‎08-29-2017 10:45 AM
Hi Harish,
As you said when ticket is updated in third party application then it should update the same in ServiceNow.
Are you saying that you have exposed the Scripted REST API to the third party.
I could see that you have used PUT method i.e. fine.
But the way you are fetching the response is incorrect . use following
var requestBody = request.body.dataString;
try to add logs to check requestBody is received correctly in your scripted rest api resource
also you are not sending the id as json key while consuming the REST endpoint so how you will get the value by parsing the json
the json parsing you have used is not correct. use following
var parser = new global.JSON();
var parsedData = parser.decode(requestBody);
var id = parsedData.work_notes;
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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-20-2018 02:58 PM
Hello,
I need to create a Webservice API where input is: Sys ID of any record and output is: all *related* active records to that sys id. The relationships between the tables is maintained in Relationships under system definition.
Could you please guide me how to implement this? Sample code would be great.
Input: Sys ID of the record
Output: All *RELATED* active records from *VARIOUS* tables (in the following JSON format):
{
"result": [
{
"Sys ID": "5520267",
"CI Name": "Record 1",
"Table Name": "u_table_a"
},
{
"Sys ID": "5520367",
"CI Name": "Record 2",
"Table Name": "u_table_a"
},
{
"Sys ID": "8331210",
"CI Name": "Record 1",
"Table Name": "u_table_b"
},
{
"Sys ID": "8321210",
"CI Name": "Record 2",
"Table Name": "u_table_b"
},
{
"Sys ID": "3042006",
"CI Name": "Record 3",
"Table Name": "u_table_b"
},
{
"sys_id": "4509847",
"CI Name": "Record 1",
"Table Name": ""u_table_c"
}
{
"sys_id": "4509247",
"CI Name": "Record 2",
"Table Name": ""u_table_c"
}
]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 11:57 PM
Hi Harish,
Any update on this?
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
‎08-30-2017 02:26 AM
Hi Ankur,
Thanks for the Response. I am still working on it. I will post you the update.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2017 03:10 AM
Hi Ankur,
As per your guidance, I have modified the code and I changed the code as below in SCRIPTED REST Api
please see the screenshot.
SCRIPT INCLUDE:
Please correct me in Script include.
ID is the unique field. Based on this field record should get updated in servicenow.
In servicenow u_zendesk_ticket_id is the field mapped against to the field ID.
Thank you.