We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7547794 commit 5ed3841Copy full SHA for 5ed3841
1 file changed
Core ServiceNow APIs/GlideAggregate/Get top 5 CIs with most number of Open Incidents/getCIwithmostActiveInc.js
@@ -0,0 +1,24 @@
1
+var countOfCI = 5;
2
+var inc = new GlideAggregate('incident');
3
+inc.addActiveQuery();
4
+inc.addAggregate('COUNT', 'cmdb_ci');
5
+inc.groupBy('cmdb_ci');
6
+inc.orderByAggregate('COUNT', 'cmdb_ci');
7
+inc.setLimit(countOfCI);
8
+inc.query();
9
+gs.info('---Top ' + countOfCI + ' CIs with Most Open Incidents---');
10
+
11
12
+while (inc.next()) {
13
+ var ciName;
14
+ var ciSysID = inc.cmdb_ci;
15
+ var count = inc.getAggregate('COUNT', 'cmdb_ci');
16
+ var ci = new GlideRecord('cmdb_ci');
17
+ if (ci.get(ciSysID)) { //retrieving the CI record
18
+ ciName = ci.name.toString();
19
+ } else {
20
+ ciName = 'Invalid CI';
21
+ }
22
23
+ gs.info('. CI: ' + ciName + ' | Count of Inc: ' + count);
24
+}
0 commit comments