Simplifying Glide Aggregate - Real use cases & Scripts - II

Nilay_Potdukhe
Tera Contributor

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 addEncodedQueryl'activestrue').

count.addQuery('category=software');

 

count.addAggregate ('COUNT');

 

count.query();

 

if (count.next()) {

 

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

 

}

 

0 REPLIES 0