File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
Core ServiceNow APIs/GlideAggregate/Count incidents based on category Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 1- Go to background and execute the script then you will get the total count of incidents based on category.
1+ A background script that aggregates incident records by category and counts how many incidents exist in each category.
22
3- It will easily help to segregate the data based on categories/priority/ etc anything.
3+ ## How it works
4+
5+ The script:
6+ 1 . Creates a ` GlideAggregate ` query on the "incident" table.
7+ 2 . Adds a COUNT aggregation on the "category" field to count the incidents per category.
8+ 3 . Orders results alphabetically by category.
9+ 4 . Executes the query and loops through the results.
10+ 5 . Logs the counts for each category to the system log.
11+
12+ ## Sample Output
13+
14+ ```
15+ The total number of Hardware categories is 25
16+ The total number of Network categories is 42
17+ The total number of Software categories is 58
18+ ```
19+
20+ ## Configuration Options
21+
22+ - ** Variable naming** : The ` categories ` should be a singular "category" since it holds one value at a time.
23+ - ** Missing encoding** : It should use `incidents.getValue('category') for proper encoding.
24+ - ** No null handling** : Any categories with no value will show as empty.
You can’t perform that action at this time.
0 commit comments