- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 07:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 08:08 PM
Hi @Mushir ,
you can try below code to get the count
var slaBreached =0;
var slaGr = new GlideAggregate("task_sla");
slaGr.addQuery("task.sys_class_name=incident^has_breached=true");
slaGr.addAggregate("COUNT");
slaGr.query();
while(slaGr.next()){
slaBreached=slaGr.getAggregate("COUNT");
}
gs.print("Count incident which SLA has been breached "+slaBreached);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 08:47 PM
Hi @Mushir ,
You can use below script.
var slaBreached = 0;
var slaGr = new GlideAggregate("task_sla");
// Query for breached SLAs related to incidents
slaGr.addQuery("task.sys_class_name", "incident");
slaGr.addQuery("has_breached", true);
slaGr.addAggregate("COUNT");
slaGr.query();
// Fetch the count directly without looping
if (slaGr.next()) {
slaBreached = slaGr.getAggregate("COUNT");
}
// Print the result
gs.print("Count of incidents with breached SLAs: " + slaBreached);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:16 PM
Hi Bhavya
can you explain me sys_class_name field where i can find it in my PDI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:20 PM
Hi Runjay
can you explain me about sys_class_name field where i can find it in my PDI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 07:13 AM
Hi @Mushir ,
Table Inheritance: ServiceNow uses a system where tables are organized in a hierarchy, with child tables inheriting from parent tables. The sys_class_name field shows which table or class a record belongs to. For example, a record in the incident table will have a sys_class_name of “incident,” but if the record is part of a different class, like “problem,” it will show that class name instead.
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 08:08 PM
Hi @Mushir ,
you can try below code to get the count
var slaBreached =0;
var slaGr = new GlideAggregate("task_sla");
slaGr.addQuery("task.sys_class_name=incident^has_breached=true");
slaGr.addAggregate("COUNT");
slaGr.query();
while(slaGr.next()){
slaBreached=slaGr.getAggregate("COUNT");
}
gs.print("Count incident which SLA has been breached "+slaBreached);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:16 PM
Hi Bhavya
can you explain me sys_class_name field where i can find it in my PDI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 08:47 PM
Hi @Mushir ,
You can use below script.
var slaBreached = 0;
var slaGr = new GlideAggregate("task_sla");
// Query for breached SLAs related to incidents
slaGr.addQuery("task.sys_class_name", "incident");
slaGr.addQuery("has_breached", true);
slaGr.addAggregate("COUNT");
slaGr.query();
// Fetch the count directly without looping
if (slaGr.next()) {
slaBreached = slaGr.getAggregate("COUNT");
}
// Print the result
gs.print("Count of incidents with breached SLAs: " + slaBreached);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:20 PM
Hi Runjay
can you explain me about sys_class_name field where i can find it in my PDI