From c8e07975d71886505316c65264be436035e10f6f Mon Sep 17 00:00:00 2001 From: ShuGitHub2022 <107590375+ShuGitHub2022@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:43:14 -0700 Subject: [PATCH] Create top 5 users --- .../Top 5 Users with Most Incidents/top 5 users | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Core ServiceNow APIs/GlideAggregate/Top 5 Users with Most Incidents/top 5 users diff --git a/Core ServiceNow APIs/GlideAggregate/Top 5 Users with Most Incidents/top 5 users b/Core ServiceNow APIs/GlideAggregate/Top 5 Users with Most Incidents/top 5 users new file mode 100644 index 0000000000..f3b99bb428 --- /dev/null +++ b/Core ServiceNow APIs/GlideAggregate/Top 5 Users with Most Incidents/top 5 users @@ -0,0 +1,14 @@ +var ga = new GlideAggregate('incident'); +ga.addAggregate('COUNT', 'sys_id'); +ga.groupBy('caller_id'); +ga.orderByAggregate('COUNT','sys_id'); +ga.setLimit(4); +ga.query(); + + +while (ga.next()) { + var count = ga.getAggregate('COUNT', 'sys_id'); //get the count + var userName = ga.getDisplayValue('caller_id');//get user's userName + + gs.log('user: ' + userName + ', Incident count: ' + count);//print out the result +}