Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

GlideAggregate MAX Returning Multiple Values Instead of a Single Maximum Value

NishmithaS
Tera Contributor

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=300
The 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




0 REPLIES 0