Scoped GlideAggregate - addAggregate(String agg, String name)

Adds an aggregate.

Table 1. Parameters
Name Type Description
agg String Name of the aggregate to add, for example, COUNT, MIN, or MAX
name String Name of the column to aggregate. Null is the default.
Table 2. Returns
Type Description
void
var count = new GlideAggregate('incident');
count.addAggregate('COUNT');
count.query();
var incidents = 0;
if (count.next()) {
   incidents = count.getAggregate('COUNT');
}
//Number of incidents varies depending on the current state
//of the incident table
gs.info('Number of incidents: ' + incidents);