121. New Method in GlideAggregate
There is an additional method available in the GlideAggregate class in the Washington DC release. It groups results by year for day-of-week trends. These trends are created using the addTrend() method with the dayofweek time interval.
Script:
var incidentGroup = new GlideAggregate(‘incident’);
incidentGroup.addTrend(‘sys_created_on’, ‘dayofweek’);
incidentGroup.addAggregate(‘COUNT’);
incidentGroup.setIntervalYearIncluded(false);
incidentGroup.query();
while (incidentGroup.next()) {
gs.info(incidentGroup.getValue(‘timeref’) + ‘: ‘ + incidentGroup.getAggregate(‘COUNT’))};
Output:
[0:00:00.049] Script completed in scope global: script
Script execution history and recovery available here
*** Script: Monday: 8
*** Script: Tuesday: 8
*** Script: Wednesday: 18
*** Script: Thursday: 8
*** Script: Friday: 13
*** Script: Saturday: 16
https://medium.com/@LearnITbyPrashant/121-new-method-in-glideaggregate-ede5514f6886?source=rss-d005fc598f0a------2