- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:12 AM
Hi
I a m trying to execute the below script and getting NAN for assignment group, plesae advise
This Query is to getting the list of incident as per assignment group
var gr= new GlideAggregate('incident');
gr.addQuery('active',true);
gr.addAggregate('COUNT');
gr.groupBy('assignment_group.name');
gr.query();
while(gr.next())
{
var countof=gr.getAggregate('COUNT');
gs.print(+gr.getDisplayValue('assignment_group.name'));
gs.print("count of assignment group is" +countof);
}
Query result:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:41 AM
Hi @srininaidu ,
Please find the below script that works for me.
var gr= new GlideAggregate("incident");
gr.addQuery("active",true);
gr.addAggregate("COUNT");
gr.groupBy("assignment_group");
gr.query();
while(gr.next()){
var countOf=gr.getAggregate("COUNT");
var groupName=gr.getDisplayValue("assignment_group");
gs.print(countOf);
gs.print(groupName);
}
Please find the screenshot attached below :
Please mark this answer as "Helpful" and correct if this answer helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:36 AM - edited 09-23-2024 10:38 AM
You have an errant + in the gs.print command, and either use gr.getValue('name') or gr.getDisplayValue('assignment_group')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 10:41 AM
Hi @srininaidu ,
Please find the below script that works for me.
var gr= new GlideAggregate("incident");
gr.addQuery("active",true);
gr.addAggregate("COUNT");
gr.groupBy("assignment_group");
gr.query();
while(gr.next()){
var countOf=gr.getAggregate("COUNT");
var groupName=gr.getDisplayValue("assignment_group");
gs.print(countOf);
gs.print(groupName);
}
Please find the screenshot attached below :
Please mark this answer as "Helpful" and correct if this answer helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 11:25 AM
Thanks, its working now