Skip to content

Incident escalation and notifications #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Business Rules/Auto Incident Notification and Escalation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Complex Incident Escalation and Notification

## Description
This project demonstrates how to implement a complex Business Rule for incident escalation and notification in ServiceNow. The Business Rule escalates incidents based on priority and time elapsed since creation, notifies the assigned group and incident manager, reassigns the incident to a higher support group if the SLA is breached, and logs all actions taken for auditing purposes.

## Features
- Escalate incidents based on priority and time elapsed since creation.
- Notify the assigned group and incident manager.
- Automatically reassign incidents to a higher support group if the SLA is breached.
- Log all actions taken by the Business Rule.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Business Rule: Complex Incident Escalation
// Escalate incidents based on priority and time elapsed since creation.
// Notify the assigned group and incident manager.
(function executeRule(current, previous /*null when async*/) {
// Constants
var ESCALATION_THRESHOLD_HOURS = 4;
var SLA_BREACH_THRESHOLD_HOURS = 8;
var HIGHER_SUPPORT_GROUP = 'High Priority Support';

// Calculate time elapsed since incident creation
var timeElapsed = gs.dateDiff(current.getValue('sys_created_on'), gs.nowDateTime(), true);

// Check if the incident is unresolved and time elapsed exceeds the escalation threshold
if (current.getValue('state') != 6 && timeElapsed > ESCALATION_THRESHOLD_HOURS * 3600) {
// Escalate the incident by updating its priority
current.setValue('priority', Math.max(1, current.getValue('priority') - 1));
gs.addInfoMessage('Incident priority has been escalated.');

// Notify the assigned group and incident manager
var assignedGroup = current.getValue('assignment_group');
var incidentManager = current.getValue('u_incident_manager');
gs.eventQueue('incident.escalation.notification', current, assignedGroup, incidentManager);

// Check if the SLA is breached
if (timeElapsed > SLA_BREACH_THRESHOLD_HOURS * 3600) {
// Reassign the incident to a higher support group
current.setValue('assignment_group', HIGHER_SUPPORT_GROUP);
gs.addInfoMessage('Incident has been reassigned to a higher support group due to SLA breach.');
}

// Log all actions taken
var logMessage = 'Incident escalated. Priority: ' + current.getValue('priority') + ', Assigned Group: ' + assignedGroup + ', Incident Manager: ' + incidentManager;
gs.log(logMessage, 'ComplexIncidentEscalation');
}
})(current, previous);