How to convert a gliderecord to JSON?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 03:25 PM
Hello,
I am trying to pull a gliderecord from a table and insert it into an JSON object but for some reason my code is not working.
Any ideas?
getRollups();
function getRollups(){
var myRollUps = [];
var table = new GlideRecord('random_table');
table.query();
while (table.next()) {
var allocation = 'Applications';
var percentage = table.u_total_app_cost;
myRollUps.push({
'rollupKey': 'name',
'rollupValue': allocation,
'rollupAmount': percentage
});
}
return myRollUps;
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 03:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 03:51 PM
My blog post GQL (Glide Query Language) Part 4: The Retriever might provide additional examples and ideas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 04:07 PM
I replaced Line 10 with:
var json = new global.JSON().encode(table.u_total_app_cost);
and then changed Line 14 to equal json
Is this how it's supposed to be used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 04:07 PM
Btw~ Thank you for all your help thus far!!!!!!!