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 de3ed58 commit 395dfd8Copy full SHA for 395dfd8
Core ServiceNow APIs/GlideAggregate/Count All Open Incidents Per Priority/script.js
@@ -0,0 +1,23 @@
1
+(function() {
2
+ // Create GlideAggregate object on 'incident' table
3
+ var ga = new GlideAggregate('incident');
4
+
5
+ // Filter only open incidents (state != Closed (7))
6
+ ga.addQuery('state', '!=', 7);
7
8
+ // Group results by priority
9
+ ga.groupBy('priority');
10
11
+ // Count number of incidents per priority
12
+ ga.addAggregate('COUNT');
13
14
+ ga.query();
15
16
+ gs.info('Open Incidents by Priority:');
17
18
+ while (ga.next()) {
19
+ var priority = ga.priority.getDisplayValue(); // e.g., Critical, High
20
+ var count = ga.getAggregate('COUNT');
21
+ gs.info(priority + ': ' + count);
22
+ }
23
+})();
0 commit comments