PrashantLearnIT
Tera Sage

Hello Everyone,

 

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

 

If my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL

 

Best Regards,

Prashant Kumar (LearnIT)

 

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635