-
Notifications
You must be signed in to change notification settings - Fork 683
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
Lacah
merged 7 commits into
ServiceNowDevProgram:main
from
MYaswanth28:Incident-Escalation-and-Notifications
Oct 29, 2024
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a27dd3d
Create ConditionsandScriptLogic
MYaswanth28 ebf76dc
Create incident_notification.js
MYaswanth28 2bb2314
Create README.md
MYaswanth28 43613be
Delete Business Rules/ConditionsandScriptLogic
MYaswanth28 1f02a84
Update incident_notification.js
MYaswanth28 df5859a
Update incident_notification.js
MYaswanth28 3b23468
Merge branch 'main' into Incident-Escalation-and-Notifications
MYaswanth28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
Business Rules/Auto Incident Notification and Escalation/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
35 changes: 35 additions & 0 deletions
35
Business Rules/Auto Incident Notification and Escalation/incident_notification.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
MYaswanth28 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.