Regarding priority in incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 09:26 PM
I want to calculate the count of all the p1,p2 and p3 incidents in last 3 months. please provide script for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 11:18 PM - edited 02-26-2024 09:25 AM
Hi @SNOW24 ,
Please try below script.
gs.info("Priority wise Incident Count :" +incCount);
Understanding GlideAggregate (servicenow.com)
Please mark Helpful & correct answer if it's solved your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 11:42 PM
Hi @SNOW24 ,
To calculate the count of incidents with priority P1, P2, and P3 in the last 3 months in ServiceNow, you can use a GlideAggregate query in a script. Here's a sample script you can use:
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.addQuery('priority', 'IN', ['1', '2', '3']);
ga.addQuery('sys_created_on', '>=', gs.beginningOfLast3Months());
ga.addQuery('active', true);
ga.groupBy('priority');
ga.query();
var p1Count = 0;
var p2Count = 0;
var p3Count = 0;
while (ga.next()) {
var priority = ga.getValue('priority');
var count = parseInt(ga.getAggregate('COUNT'), 10);
if (priority == '1') {
p1Count = count;
} else if (priority == '2') {
p2Count = count;
} else if (priority == '3') {
p3Count = count;
}
}
gs.info('P1 Count: ' + p1Count);
gs.info('P2 Count: ' + p2Count);
gs.info('P3 Count: ' + p3Count);
Please click Accepted as Solution & hit helpful button !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 01:03 AM - edited 02-23-2024 01:15 AM
Hi @SNOW24 ,
You can create a simple Dashboard and add single score 3 reports(p1,p2,p3) so that it will be dynamic and you can use it whenever needed
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang