Glide Aggregate
It is a server-side ServiceNow API, used to perform aggregate operations like COUNT, SUM, AVG, MIN, and MAX on table records without retrieving full record data
Methods of Glide Aggregate -:
- addAggregate(aggregate, fieldname)
-> Adds an aggregate function like COUNT, SUM, AVG, MIN, MAX on a given field.
- GroupBy
-> Groups the records based on the supplied field.
- Order By
-> Sorts the result in ascending order.
- OrderByDesc
-> Sorts the result in descending order by the given field.
- query()
-> Executes the database query.
- next ().
-> Moves to the next aggregated record.
- GetAggregate.
-> Gives you the final calculated answer (like total count or total sum). - GetValue.
-> Gives you the value stored in a field for that record. - addEncodedQuery(query String)-
-> Adds a ready-made filter to get only the records you want. - setGroup(Boolean)
-> Tells the system to group similar records together. - SetHavingCondition
-> Filters the grouped results based on total/count/sum values. - SetLimit.
-> Tells the system to return only a limited number of records.
Example -:
1). Using GlideAggregate in ServiceNow, how many incidents are grouped by category?
Output -:
2. To find number of incidents active true
Output -:
Glide Aggregate
