GlideAggregate - groupBy(String name)

Provides the name of a field to use in grouping the aggregates.

May be called numerous times to set multiple group fields.

Table 1. Parameters
Name Type Description
name String Name of the field.
Table 2. Returns
Type Description
void

Scoped equivalent

To use the groupBy() method in a scoped application, use the corresponding scoped method: .Scoped GlideAggregate - groupBy(String name).

 var count = new GlideAggregate('incident');
  count.addAggregate('MIN', 'sys_mod_count');
  count.addAggregate('MAX', 'sys_mod_count');
  count.addAggregate('AVG', 'sys_mod_count');
  count.groupBy('category');
  count.query();   
  while (count.next()) {  
     var min = count.getAggregate('MIN', 'sys_mod_count');
     var max = count.getAggregate('MAX', 'sys_mod_count');
     var avg = count.getAggregate('AVG', 'sys_mod_count');
     var category = count.category.getDisplayValue();
     gs.log(category + " Update counts: MIN = " + min + " MAX = " + max + " AVG = " + avg);
  }