I want to print groupby assignmentgroup and with count,numbers as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2025 01:21 AM
I want to print groupby assignmentgroup and with count,numbers as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2025 01:54 PM
Hi @ganeshnerni
You did not give the full details so assuming you are referring to the Incident report.
Table: Incident
Report Type : Bar
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
03-30-2025 04:13 AM
Hi @ganeshnerni ,
You can use below script for your use case.
var inc_count;
var ga_inc = new GlideAggregate("incident");
ga_inc.addAggregate("COUNT","assignment_group");
ga_inc.query();
while(ga_inc.next())
{
var c=1;
inc_count = ga_inc.getAggregate("COUNT","assignment_group");
if(ga_inc.assignment_group)
{
gs.info("Assignment Group: " + ga_inc.assignment_group.getDisplayValue() + " have " + inc_count + " number of incidents." + ga_inc.number);
var gr_inc = new GlideRecord("incident");
gr_inc.addQuery("assignment_group",ga_inc.assignment_group);
gr_inc.query();
while(gr_inc.next())
{
gs.info("S.No: " + c + " " + gr_inc.number);
c=c+1;
}
}
else
{
gs.info("Assignment Group is empty and have " + inc_count + " number of incidents.");
var gr_inc = new GlideRecord("incident");
gr_inc.addQuery("assignment_group",ga_inc.assignment_group);
gr_inc.query();
while(gr_inc.next())
{
gs.info("S.No: " + c + " " + gr_inc.number);
c=c+1;
}
}
}
Refer the snip
Output: Incident list view grouped by assignment group, showing the count of incidents for each group and printing the incident number for each assignment group.
Incident List View Group By Assignment Group
If my response helped, then accept the solution and hit the thumbs up, so that it benefits the future reader and also me for your efforts towards the community.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 08:14 AM
Hi @ganeshnerni ,
Did you check my solution?
If helpful then please accept the solution and hit thumbs up so that it benefits future reader.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 12:09 PM
Hi @ganeshnerni ,
Hope you are doing good. Did you check my solution?
If my response helped, then accept the solution and hit the thumbs up, so that it benefits the future reader and also me for your efforts towards the community.
Regards,
Rohit