- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 07:36 AM
Hi,
I have a report that lists the number of calls created that day using an email script:
The email script is:
var agg = new GlideAggregate('incident');
agg.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg.addAggregate('count', 'assignment_group');
agg.orderBy('assignment_group');
agg.query();
while (agg.next()) {
var assignment_group = agg.assignment_group;
var count = agg.getAggregate('count', 'assignment_group');
template.print("<li> " + assignment_group.getDisplayValue() + ": Current number of incidents: " + count + "</span></li>");
}
Is it possible to create a different count to these results too? e.g. the number of incidents resolved by each assignment group?
Cheers,
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 09:11 AM
I have not tested the code...but may be in the following lines will work
var agg = new GlideAggregate('incident');
agg.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg.addAggregate('count', 'assignment_group');
agg.orderBy('assignment_group');
agg.query();
while (agg.next()) {
var assignment_group = agg.assignment_group;
var count = agg.getAggregate('count', 'assignment_group');
var agg2 = new GlideAggregate('incident');
agg2.addEncodedQuery('assignment_group=' +assignment_group+ '^resolved_atONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg2.addAggregate('count', 'assignment_group');
agg2.query();
var r_count = 0;
while (agg2.next()) {
r_count = agg2.getAggregate('count', 'assignment_group');
}
template.print("<li> " + assignment_group.getDisplayValue() + ": Current number of incidents: " + count + ": resolved incidents: " + r_count +"</span></li>");
}
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 07:51 AM
declare variables for each aggregate and collect them.
var incidents_created_today;
var incidents_resolved_today;
while (agg.next()) {
var assignment_group = agg.assignment_group;
var count = agg.getAggregate('count', 'assignment_group');
incidents_created_today = "<li> " + assignment_group.getDisplayValue() + ": Current number of incidents: " + count + "</span></li>"
}
//similarly collect incidents_resolved_today with a different GlideAggregate('incident');
//Finally print to the template
template.print(incidents_created_today + "<br>" + incidents_resolved_today);
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 08:51 AM
Many thanks for the reply.
Will that make 2 lists after each other.
i.e.
Service Desk opened 10
Deskside opened 3
Network opened 5
Database opened 11
Service Desk resolved 8
Deskside resolved 2
Network resolved 2
Database resolved 1
Would it be possible to have them as:
Service Desk opened 10, resolved 8
Deskside opened 3, resolved 2
Network opened 5, resolved 2
Database opened 11, resolved 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 09:11 AM
I have not tested the code...but may be in the following lines will work
var agg = new GlideAggregate('incident');
agg.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg.addAggregate('count', 'assignment_group');
agg.orderBy('assignment_group');
agg.query();
while (agg.next()) {
var assignment_group = agg.assignment_group;
var count = agg.getAggregate('count', 'assignment_group');
var agg2 = new GlideAggregate('incident');
agg2.addEncodedQuery('assignment_group=' +assignment_group+ '^resolved_atONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
agg2.addAggregate('count', 'assignment_group');
agg2.query();
var r_count = 0;
while (agg2.next()) {
r_count = agg2.getAggregate('count', 'assignment_group');
}
template.print("<li> " + assignment_group.getDisplayValue() + ": Current number of incidents: " + count + ": resolved incidents: " + r_count +"</span></li>");
}
Vinod Kumar Kachineni
Community Rising Star 2022