- 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 10:46 PM
where should we see the output of these scripts

- 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 11:23 PM
thanks for your help omkar it is working fine but i want with business rule that i shared the screen shot of busines rule where should we see the output of the result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 11:29 PM
Hi
You can add a gs.log() if you want. The thing is GlideAggregate will work, but if you want to see the chaqnges, create a field and then set the value to the field on incident form.
Something like this :-
var count =new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents =0;
if(count.next())
{
incidents = count.getAggregate('COUNT');
count.setValue('u_new_field',incidents);
}
Regards.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 11:31 PM
Hello preddy
Here is how you can do this
Create a BR on incident table.
Select before and Query
And in advanced, add below code
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var count = new GlideAggregate('incident');
count.addAggregate("COUNT");
count.query();
var total_incidents = 0;
if(count.next()) {
total_incidents = count.getAggregate("COUNT");
}
gs.addInfoMessage("count of incidents are "+total_incidents);
})(current, previous);
This will print the output on incident list.
Kindly mark my answer as correct if this helps.