Json code into ServiceNow Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 06:11 AM
i have get the Below data from REST API from another third-party tool, the response like below.
Json format:
"totalCount" : 1122,
"results" : [ {
"id" : "198232323",
"id2" : "11122-2-32312312",
"general" : {
"name" : "Apple’s Macoo",
"lastIpAddress" : "1121.2223.222.111",
"lastReportedIp" : "1212.2121.121.212",
"jamfBinaryVersion" : "112110.12121.0-1212121",
"platform" : "Mac",
"barcode1" : null,
"barcode2" : null,
"assetTag" : null,
"remoteManagement" : {
"managed" : true,
"managementUsername" : "adddadasdwd"
},
"supervised" : true,
"mdmCapable" : {
"capable" : true,
"capableUsers" : [ ]
},
I want to update these data into a custom table and all the attributes are there in costum tables.
Please suggest how can we update these data in the table.
i tried the below option but it didn't work
var obj = JSON.parse(responseBody);
var chuck = new GlideRecord('table');
chuck.order = obj.id;
chuck.number = obj.name;
chuck.c_id = obj.lastIpAddress;
chuck.insert();
chuck.description = obj.lastReportedIp;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 08:43 AM
Hi @Royal1 ,
Please try the script like below.
var responseObj = JSON.parse(responseBody);
var name = responseObj.name;
var email = responseObj.email;
var age = responseObj.age;
var gr = new GlideRecord('your table');
gr.initialize();
gr.name = name;
gr.email = email;
gr.age = age;
gr.insert();
refer the below link.
If my answer resolves your issue then please mark it as correct and helpful.
Regards,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:36 AM
no luck , unable to get the data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 11:41 AM
Hello @Royal1,
Please try this :