Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
3 weeks ago
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);
}
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆
☆ Community Rising Star 22, 23 & 24 ☆
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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);
}
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆
☆ Community Rising Star 22, 23 & 24 ☆
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
