- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 11:57 PM
Hi Team,
I have a requirement to show the number of incidents based on categories. Can anyone help me with the script to show these records as it is below:
Hardware :12
Software : 3
Database : 23
Inquiry/Help : 40
Regards
Souvick
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 12:00 AM
Hi @Souvick A
Please use below script:
var incidents = new GlideAggregate('incident');
incidents.addAggregate('count', 'category'); // Add an aggregate to count based on category field
incidents.orderBy('category');
incidents.query();
while (incidents.next()) {
// Get the current category and count
var category = incidents.category;
var count = incidents.getAggregate('count', 'category');
gs.info('Category: ' + category + ' Count: ' + count);
}
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 12:00 AM
Hi @Souvick A
Please use below script:
var incidents = new GlideAggregate('incident');
incidents.addAggregate('count', 'category'); // Add an aggregate to count based on category field
incidents.orderBy('category');
incidents.query();
while (incidents.next()) {
// Get the current category and count
var category = incidents.category;
var count = incidents.getAggregate('count', 'category');
gs.info('Category: ' + category + ' Count: ' + count);
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 12:20 AM
Thank you Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 07:31 AM
Hi I need to display the incident numbers as well, could anyone help?? Like if software category has 4 incidents under it I have to display it like
Category software count 4
INC0001
INC0002
INC0003
INC0004
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 02:00 AM
Hello @Aman Kumar S ,
Even I am also looking for the script to get the count of category and the incident numbers of that each as well. Can anyone help?
Thanks