- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 07:20 PM
what is the glide aggregate function?how to use
Solved! Go to Solution.
- Labels:
-
Field Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 10:50 PM
Hi
Please try it in the background script :-
var count =new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents =0;
if(count.next())
{
incidents = count.getAggregate('COUNT');
gs.print(incidents);
}
Copy paste this code in Background script.
See below :-
Regards,
Omkar Mone.
www.dxsherpa.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 07:44 PM
Please find below link
The GlideAggregate class is an extension of GlideRecord and allows database aggregation (COUNT, SUM, MIN, MAX, AVG) queries to be done. This can be helpful in creating customized reports or in calculations for calculated fields.
Note: Please mark reply as correct if it has answered your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 07:52 PM
where we need to wright these scripts to get the count of a table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 08:46 PM
Hi ,
The GlideAggregate class is an extension of GlideRecord and allows database aggregation (COUNT, SUM, MIN, MAX, AVG) queries to be done. This can be helpful in creating customized reports or in calculations for calculated fields.
GlideAggregate examples
count of the number of records
var count = new GlideAggregate('incident'); count.addAggregate('COUNT'); count.query(); var incidents = 0; if(count.next()) incidents = count.getAggregate('COUNT');
count of the incidents that were open
var count = new GlideAggregate('incident'); count.addQuery('active','true'); count.addAggregate('COUNT'); count.query(); var incidents = 0; if(count.next()) incidents = count.getAggregate('COUNT');
open incidents by category
var count = new GlideAggregate('incident'); count.addQuery('active','true'); count.addAggregate('COUNT','category'); count.query(); while(count.next()){ var category = count.category; var categoryCount = count.getAggregate('COUNT','category'); gs.log("there are currently "+ categoryCount +" incidents with a category of "+ category);}
https://docs.servicenow.com/bundle/jakarta-application-development/page/script/glide-server-apis/con...
Please mark it as correct
Regards,
Sindhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 09:25 PM
where should i wright these scripts?and the entire script i need to wright that you have given?