Category: Scenario-Based Questions PART 32
Updated on: August 12, 2025  |  0

Scenario-Based Questions PART 32

🎓 Scenario-Based Question

📌 Use Case: Get the Count of Incidents with Breached SLA

This use case demonstrates how to use GlideAggregate to find the number of incidents whose associated SLAs have been breached.


🛠 Steps to Implement:

  1. Identify the Data Source
    • Table: task_sla
    • Filter: task.sys_class_name = "incident" and has_breached = true
  2. Write the Script
    • Use GlideAggregate to group and count results efficiently
    var breachedSLA = 0;
    var slaGR = new GlideAggregate("task_sla");
    slaGR.addQuery("task.sys_class_name", "incident"); 
    slaGR.addQuery("has_breached", true);
    slaGR.addAggregate("COUNT");
    slaGR.query();
    
    if (slaGR.next()) {
        breachedSLA = slaGR.getAggregate("COUNT");
    }
    gs.print("Count of incidents with breached SLAs: " + breachedSLA);
          
  3. Run & Verify
    • Execute in Background Scripts or scheduled script execution
    • Check system logs for the printed count

💡 Pro Tip:

 

  • GlideAggregate is preferred over GlideRecord when you only need counts or summaries — it’s faster and uses less memory.
  • You can extend this query to group by priority, assignment group, or SLA definition for deeper reporting.

 

Comments

No comments yet.


Log in to post a comment