- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 04:43 AM
I've created a remote table that queries an external data source, and I want a count of the records that satisfy a specific query.
This script returns null:
var sections = new GlideAggregate('x_uob15_canvas_adm_st_course_section');
sections.addQuery('course.sis_id', 'C2023-B08835').addCondition('start_at', '>', '2024-09-01 00:00:00');
sections.addAggregate('COUNT');
sections.query();
gs.print(sections.getAggregate('COUNT'));This script returns NaN:
var sections = new global.GlideQuery('x_uob15_canvas_adm_st_course_section')
.where('course.sis_id', 'C2023-B08835').where('start_at', '>', '2024-09-01 00:00:00')
.count();
gs.print(sections);
However, these scripts return the expected result:
var sections = new GlideRecord('x_uob15_canvas_adm_st_course_section');
sections.addQuery('course.sis_id', 'C2023-B08835').addCondition('start_at', '>', '2024-09-01 00:00:00');
sections.query();
gs.print(sections.getRowCount());OR
var sections = new global.GlideQuery('x_uob15_canvas_adm_st_course_section')
.where('course.sis_id', 'C2023-B08835').where('start_at', '>', '2024-09-01 00:00:00')
.select().toArray(100).length;
gs.print(sections);
I cannot find documentation on aggregate methods in the v_query API.
Has anyone successfully used GlideAggregate on a remote table?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2025 12:19 AM
Hi @Colleen
GlideAggregate (and GlideQuery’s .count()) don’t work on Remote Tables. Remote Tables only implement a subset of query operations; aggregate functions aren’t supported, so you get null/NaN. Your two “working” snippets succeed because they materialize rows (or at least a page of them) and then count locally.
var q = new global.GlideQuery('x_uob15_canvas_adm_st_course_section')
var count = q.toArray(1000).length;
gs.print(count);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2025 07:06 AM
Hi, in the first example, it looks like a call to sections.next() is missing after the query..
if (sections.next() {
...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2025 07:44 AM - edited 09-06-2025 07:45 AM
GligeAggregate is used for database aggregation queries. Refer below documentation for usage,
Change your query to below
var sections = new GlideAggregate('x_uob15_canvas_adm_st_course_section');
sections.addQuery('course.sis_id', 'C2023-B08835').addCondition('start_at', '>', '2024-09-01 00:00:00');
sections.addAggregate('COUNT','field_name');
sections.query();
while(sections.next())
{
gs.print(sections.getAggregate('COUNT','field_name'));
}Below is a sample,
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2025 10:37 PM
Did you get a chance to review this ?
If my response helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2025 12:24 AM
Hi Bhuvan
I was already aware of the GlideAggregrate API. I was looking for a solution using GlideQuery since it is a neater, more modern interface.