Skip to content

Commit c8e0797

Browse files
Create top 5 users
1 parent fa52e46 commit c8e0797

File tree

1 file changed

+14
-0
lines changed
  • Core ServiceNow APIs/GlideAggregate/Top 5 Users with Most Incidents

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var ga = new GlideAggregate('incident');
2+
ga.addAggregate('COUNT', 'sys_id');
3+
ga.groupBy('caller_id');
4+
ga.orderByAggregate('COUNT','sys_id');
5+
ga.setLimit(4);
6+
ga.query();
7+
8+
9+
while (ga.next()) {
10+
var count = ga.getAggregate('COUNT', 'sys_id'); //get the count
11+
var userName = ga.getDisplayValue('caller_id');//get user's userName
12+
13+
gs.log('user: ' + userName + ', Incident count: ' + count);//print out the result
14+
}

0 commit comments

Comments
 (0)