Skip to content

Commit 1f02a84

Browse files
authored
Update incident_notification.js
1 parent 43613be commit 1f02a84

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
//Business Rule: Complex Incident Escalation
2-
//Escalate incidents based on priority and time elapsed since creation.
3-
//Notify the assigned group and incident manager.
1+
// Business Rule: Complex Incident Escalation
2+
// Escalate incidents based on priority and time elapsed since creation.
3+
// Notify the assigned group and incident manager.
44
(function executeRule(current, previous /*null when async*/) {
55
// Constants
66
var ESCALATION_THRESHOLD_HOURS = 4;
77
var SLA_BREACH_THRESHOLD_HOURS = 8;
88
var HIGHER_SUPPORT_GROUP = 'High Priority Support';
99

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

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

1919
// Notify the assigned group and incident manager
20-
var assignedGroup = current.assignment_group.getDisplayValue();
21-
var incidentManager = current.u_incident_manager.getDisplayValue();
20+
var assignedGroup = current.getValue('assignment_group');
21+
var incidentManager = current.getValue('u_incident_manager');
2222
gs.eventQueue('incident.escalation.notification', current, assignedGroup, incidentManager);
2323

2424
// Check if the SLA is breached
2525
if (timeElapsed > SLA_BREACH_THRESHOLD_HOURS * 3600) {
2626
// Reassign the incident to a higher support group
27-
current.assignment_group.setDisplayValue(HIGHER_SUPPORT_GROUP);
27+
current.setValue('assignment_group', HIGHER_SUPPORT_GROUP);
2828
gs.addInfoMessage('Incident has been reassigned to a higher support group due to SLA breach.');
2929
}
3030

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

0 commit comments

Comments
 (0)