Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2026 12:13 AM
Hi All
I'm testing GlideAggregate with a MAX aggregate
var ga = new GlideAggregate('incident');
ga.addAggregate('MAX', 'u_cost');
ga.query();
while (ga.next()) {
gs.print('MAX=' + ga.getAggregate('MAX', 'u_cost'));
}
Expected result:
MAX=300
Actual result:
MAX=
MAX=1
MAX=100
MAX=200
MAX=300The u_cost field is of type Integer.
when i use this
if (ga.next()) {
gs.print('MAX=' + ga.getAggregate('MAX', 'u_cost'));
}
i get
MAX=
The aggregate appears to be returning values separately for each u cost value instead of a single MAX value.
Any suggestions on why GlideAggregate is not returning a single MAX value
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2026 06:57 AM
Hello @NishmithaS ,
Try this:
var ga = new GlideAggregate('incident');
ga.addAggregate('MAX', 'u_cost');
ga.setGroup(false);
ga.query();
if (ga.next()) {
var maxVal = ga.getAggregate('MAX', 'u_cost');
gs.print('The maximum value is: ' + maxVal);
}
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2026 06:57 AM
Hello @NishmithaS ,
Try this:
var ga = new GlideAggregate('incident');
ga.addAggregate('MAX', 'u_cost');
ga.setGroup(false);
ga.query();
if (ga.next()) {
var maxVal = ga.getAggregate('MAX', 'u_cost');
gs.print('The maximum value is: ' + maxVal);
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2026 01:00 AM