Scoped GlideAggregate - orderBy(String name)

Orders the aggregates using the value of the specified field. The field will also be added to the group-by list.

Table 1. Parameters
Name Type Description
name String Name of the field to order the aggregates by.
Table 2. Returns
Type Description
var agg = new GlideAggregate('incident');
agg.addAggregate('count', 'category'); 
while ( { 
  var category = agg.category;
  var count = agg.getAggregate('count', 'category');
  var agg2 = new GlideAggregate('incident');   
  agg2.addAggregate('count', 'category');
  agg2.orderBy('category'); + ": Current number of incidents:" + count);
database: Current number of incidents:2
hardware: Current number of incidents:8
inquiry: Current number of incidents:28
network: Current number of incidents:5
request: Current number of incidents:5
software: Current number of incidents:11