Write a script to print Incident count based on priority.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:33 AM
Below is my script which is not giving expected O/P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:41 AM
Hi @Parth_S
I am not a developer but these links might be helpful
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:51 AM
Hello @Parth_S ,
You can follow the below script, that will work:-
var gr = new GlideAggregate("incident");
gr.groupBy("priority");
gr.addAggregate("COUNT","priority");
gr.query();
while(gr.next()){
gs.info("Priority is: "+ gr.priority + " and count is: "+ gr.getAggregate("COUNT","priority"));
}
Please mark my solution as accepted and give thumbs up, if it helps you.
Regards,
Abhishek Thakur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:02 AM - edited 12-30-2024 03:04 AM
Hi @Parth_S ,
Use below script
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT','priority');
agg.groupBy('priority');
agg.query();
while (agg.next()) {
var priority = agg.getDisplayValue('priority');
var incidentCount = agg.getAggregate('COUNT');
gs.info('Priority: ' + priority + ', Count: ' + incidentCount);
}
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand