|
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. |
4 | 4 | (function executeRule(current, previous /*null when async*/) {
|
5 | 5 | // Constants
|
6 | 6 | var ESCALATION_THRESHOLD_HOURS = 4;
|
7 | 7 | var SLA_BREACH_THRESHOLD_HOURS = 8;
|
8 | 8 | var HIGHER_SUPPORT_GROUP = 'High Priority Support';
|
9 | 9 |
|
10 | 10 | // 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); |
12 | 12 |
|
13 | 13 | // 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) { |
15 | 15 | // 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)); |
17 | 17 | gs.addInfoMessage('Incident priority has been escalated.');
|
18 | 18 |
|
19 | 19 | // 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'); |
22 | 22 | gs.eventQueue('incident.escalation.notification', current, assignedGroup, incidentManager);
|
23 | 23 |
|
24 | 24 | // Check if the SLA is breached
|
25 | 25 | if (timeElapsed > SLA_BREACH_THRESHOLD_HOURS * 3600) {
|
26 | 26 | // Reassign the incident to a higher support group
|
27 |
| - current.assignment_group.setDisplayValue(HIGHER_SUPPORT_GROUP); |
| 27 | + current.setValue('assignment_group', HIGHER_SUPPORT_GROUP); |
28 | 28 | gs.addInfoMessage('Incident has been reassigned to a higher support group due to SLA breach.');
|
29 | 29 | }
|
30 | 30 |
|
31 | 31 | // 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; |
33 | 33 | gs.log(logMessage, 'ComplexIncidentEscalation');
|
34 | 34 | }
|
35 | 35 | })(current, previous);
|
0 commit comments