Simplifying GlideAggregate – Real Use Cases & Scripts - II💡

Community Alums
Not applicable

Real-World Scenarios Using GlideAggregate:- 

6. Minimum Updates by Category

var count = new GlideAggregate('incident');

count.addAggregate('MIN', 'sys_mod_count');

count.groupBy('category');

count.query();

while (count.next()) {

  gs.info("Category: " + count.category + " | Min Updates: " + count.getAggregate('MIN', 'sys_mod_count'));

}
7.Quarterly Incident Trends

var ga = new GlideAggregate('incident');

ga.addAggregate('COUNT');

ga.addTrend('opened_at', 'quarter');

ga.query();

while (ga.next()) {

  gs.info("Quarter: " + ga.getValue('timeref') + " | Incidents: " + ga.getAggregate('COUNT'));

}
8.Category-Wise Incident Distribution

var count = new GlideAggregate('incident');

count.addQuery('active', 'true');

count.addAggregate('COUNT', 'category');

count.query();

while (count.next()) {

  var category = count.category;

  var categoryCount = count.getAggregate('COUNT', 'category');

  gs.info("Category: " + category + " | Count: " + categoryCount);

}
9.Count Active Software Incidents

var count = new GlideAggregate('incident');

count.addEncodedQuery('active=true');

count.addQuery('category=software');

count.addAggregate('COUNT');

count.query();

if (count.next()) {

  gs.info("Active Software Incidents: " + count.getAggregate('COUNT'));

}

 

 

1 REPLY 1

Mark Manders
Mega Patron

Please start your posts with saying it's not a question, when you post it in the question part of the Community.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark