- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 12:18 PM
I want to get data from a pre-existing table and iterate through that table, putting each row into an Array.
array example:
tableData = [
[row1TableData],
[row2TableData],
];
How would I do this via Mid server script?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 12:35 PM
var arr = [];
var gr = new GlideRecord("<table>");
gr.addQuery(<query here>);
while(gr.next())
{
//pushes only only one field value
arr.push(gr.<field_value>);
}
Check this community article as well:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 12:35 PM
var arr = [];
var gr = new GlideRecord("<table>");
gr.addQuery(<query here>);
while(gr.next())
{
//pushes only only one field value
arr.push(gr.<field_value>);
}
Check this community article as well:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2020 07:01 AM
Hi,
I want to add one point in above discussion that we can also do like below
var arr = ['val1','val2','val3'];
for(var i = 0; i<arr.length; i++)
{
var gr = new GlideRecord('<Table>');
gr.addQuery('active','true');
//gr.addQuery('<field_value>,arr[i]); //here you can also compare array of value with table fields value
gr.query();
if(gr.next())
{
arr.push(gr.<field Value>);
}
}//for loop close
Thanks,
Kunal