Scoped GlideAggregate - getAggregate(String agg, String name)

Gets the value of an aggregate from the current record.

Table 1. Parameters
Name Type Description
agg String The type of the aggregate, for example, SUM or Count.
name String Name of the field to get the aggregate from.
Table 2. Returns
Type Description
String The value of the aggregate.
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);

Output: Number of incidents: 63