Category: Scenario based QA - 1
Updated on: August 2, 2025  |  0

๐’๐œ๐ž๐ง๐š๐ซ๐ข๐จ ๐›๐š๐ฌ๐ž๐ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง PART 1

๐ŸŽ“ Scenario-Based Question

Q1: How can you display inactive incidents only to ITIL Admins and hide them from all other users?

Answer:

1๏ธโƒฃ Method 1: Create a Read ACL for Inactive Incidents

๐Ÿ“Œ Purpose: Restrict access to inactive incidents only for users with the itil_admin role.

๐Ÿ”ง Setting โš™๏ธ Value
Table incident
Operation read
Condition Active = false
Roles itil_admin only

โœ… Result: Only ITIL Admins can view inactive incidents; all other users wonโ€™t see them in lists, reports, or queries.

๐Ÿ“Œ Purpose: Dynamically filter out inactive incidents for non-admins using scripting.

๐Ÿงฐ Script Example:

// Table: incident
if (!gs.hasRole('itil_admin')) {
  current.addQuery('active', true);
}

Explanation:
This script adds a filter to the query so that only active incidents are shown unless the user has the itil_admin role.

โœ… Result: Clean and dynamic approach that works behind the scenes.

2๏ธโƒฃ Method 2: Use a Before Query Business Rule

๐ŸŽฏย Recommended Approach:
  • Useย Query Business Rule if you want better performance and centralized logic.
  • Useย ACLs for fine-grained security enforcement.

ย 


Q2: Write a background script to count incidents for which SLA has been breached?

Answer:

Hereโ€™s a clean and efficient background script to count breached SLAs for incidents using GlideAggregate:

var slaBreached = 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()) {
  slaBreached = slaGr.getAggregate("COUNT");
}

// ๐๐ซ๐ข๐ง๐ญ ๐ญ๐ก๐ž ๐ซ๐ž๐ฌ๐ฎ๐ฅ๐ญ
gs.print("Count of incidents with breached SLAs: " + slaBreached);

๐Ÿ” Explanation:

  • ๐Ÿ”น Filters for task.sys_class_name = incident to ensure only Incident SLAs are included.
  • ๐Ÿ”น has_breached = true to select only breached SLA records.
  • ๐Ÿ”น Uses GlideAggregate for performance, returning the count directly.

Comments

No comments yet.


Log in to post a comment