Skip to content

Commit 81cb8a8

Browse files
committed
added custom sla breach script
1 parent 63dc0d4 commit 81cb8a8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

SlaBreach/readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Custom SLA Breach Alert
2+
3+
This script monitors SLAs and sends a notification to assignees if an SLA is about to breach within the next hour. It allows users to take preemptive action to meet SLA commitments.
4+
5+
## Usage
6+
- Place this script in a Script Include or scheduled job to monitor SLA breaches.
7+
- Customize the query for different SLA thresholds.

SlaBreach/script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(function alertSLABreach() {
2+
// Query for tasks with SLAs nearing breach within 1 hour
3+
var sla = new GlideRecord('task_sla');
4+
sla.addEncodedQuery('breach_timeRELATIVELE@hour@1');
5+
sla.query();
6+
7+
// Send alert notification
8+
while (sla.next()) {
9+
var taskNumber = sla.task.number;
10+
var assignedUser = sla.task.assigned_to;
11+
12+
if (assignedUser) {
13+
gs.eventQueue("custom.sla.breach.alert", sla.task, assignedUser, taskNumber);
14+
}
15+
}
16+
})();

0 commit comments

Comments
 (0)