- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2016 10:46 PM
Hi,
I'm able to get back Json inputs from REST message
[ {"SiteName":"SC","LabName":"SVC","UnitNumber":"M5835JC800490","MaterialLotNumber":"L542C251","ProductName":"BROADWELL EP 24C","PartTypeName":"MF 8PTSFV A B","FullLocationName":"SHIP: CR3-1-C35 Mega Lab Inventory Control","QDFNumber":"","LastVPONumber":"","LastStepName":"","LastBinName":"","MirNumber":63362,"MirRequesterWWID":"10519277","MirRecipientWWID":"10552840"},
{"SiteName":"SC","LabName":"SVC","UnitNumber":"M5424BB700234","MaterialLotNumber":"L541C677","ProductName":"BROADWELL EP 24C","PartTypeName":"MF 8PTSFV A B","FullLocationName":"SHIP: CR3-1-C35 Mega Lab Inventory Control","QDFNumber":"","LastVPONumber":"","LastStepName":"","LastBinName":"","MirNumber":63362,"MirRequesterWWID":"10519277","MirRecipientWWID":"10552840"}]
I need to insert these records into a custom table(lets say u_demo table). Kindly help me with a proper coding.
Thanks,
Rajkumar.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2016 03:13 AM
Hi Rajkumar,
There is small changes in code which i had missed earlier.
Try this latest modified code. Hope it will work!
var r = new sn_ws.RESTMessageV2('REST_name_xxxx', 'get'); // in my case, we are using Get method
var response = r.execute();
var responseBody = response.getBody(); //fetches JSON response
var response= JSON.parse(responseBody);
for(i=0;i<response.length;i++)
{
var gr = new GlideRecord('u_labname');
gr.initialize();
gr.u_fieldname = response[i].SiteName;
....................
...................
gr.insert();
}
Thanks,
Kaka Nayeem
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2019 02:23 AM
Hi,
Below code is working perfectly:
var r = new sn_ws.RESTMessageV2('Get data from other instance and update', 'Get name, id, company'); // in my case, we are using Get method
var response = r.execute();
var responseBody = response.getBody(); //fetches JSON response
var resp= JSON.parse(responseBody);
for(var i=0;i<resp.result.length;i++)
{
var gr = new GlideRecord('u_consume_data_from_sunil_dev');
gr.initialize();
gr.u_company = resp.result[i].company;
gr.u_id = resp.result[i].id;
gr.u_name = resp.result[i].name;
gr.insert();
}