Skip to content

Commit 395dfd8

Browse files
authored
script.js
1 parent de3ed58 commit 395dfd8

File tree

1 file changed

+23
-0
lines changed
  • Core ServiceNow APIs/GlideAggregate/Count All Open Incidents Per Priority

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)