From a27dd3d88537021e1b07f0577790df8c3974a92b Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:11:29 +0530 Subject: [PATCH 1/8] Create ConditionsandScriptLogic Business Rule with Conditions and Script Logic --- Business Rules/ConditionsandScriptLogic | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Business Rules/ConditionsandScriptLogic diff --git a/Business Rules/ConditionsandScriptLogic b/Business Rules/ConditionsandScriptLogic new file mode 100644 index 0000000000..1eb4e31abe --- /dev/null +++ b/Business Rules/ConditionsandScriptLogic @@ -0,0 +1,10 @@ +// Check if the Business Rule has a condition +if (!current.condition) { + gs.addErrorMessage('Business Rule without condition: ' + current.name); +} + +// Check for inefficient script logic (example: GlideRecord queries inside loops) +var script = current.script.toString(); +if (script.includes('while') && script.includes('new GlideRecord')) { + gs.addErrorMessage('Potential inefficient GlideRecord usage in Business Rule: ' + current.name); +} From 3555d68e59522eefbf43ee5f4099c623adbb6aa7 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:27:13 +0530 Subject: [PATCH 2/8] Create incident_escalation.js Incident Escalation BR --- .../incident_escalation.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Business Rules/Incident Escalation and Notifications/incident_escalation.js diff --git a/Business Rules/Incident Escalation and Notifications/incident_escalation.js b/Business Rules/Incident Escalation and Notifications/incident_escalation.js new file mode 100644 index 0000000000..f51cc61f5a --- /dev/null +++ b/Business Rules/Incident Escalation and Notifications/incident_escalation.js @@ -0,0 +1,33 @@ +// Business Rule: Complex Incident Escalation +(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.sys_created_on, gs.nowDateTime(), true); + + // Check if the incident is unresolved and time elapsed exceeds the escalation threshold + if (current.state != 'Resolved' && timeElapsed > ESCALATION_THRESHOLD_HOURS * 3600) { + // Escalate the incident by updating its priority + current.priority = Math.max(1, current.priority - 1); + gs.addInfoMessage('Incident priority has been escalated.'); + + // Notify the assigned group and incident manager + var assignedGroup = current.assignment_group.getDisplayValue(); + var incidentManager = current.u_incident_manager.getDisplayValue(); + 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.assignment_group.setDisplayValue(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.priority + ', Assigned Group: ' + assignedGroup + ', Incident Manager: ' + incidentManager; + gs.log(logMessage, 'ComplexIncidentEscalation'); + } +})(current, previous); From 4aedf783fb3faf99b8329e13c053aa7601ae3db3 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:28:54 +0530 Subject: [PATCH 3/8] Create README.md README.md File for BR --- .../Incident Escalation and Notifications/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Business Rules/Incident Escalation and Notifications/README.md diff --git a/Business Rules/Incident Escalation and Notifications/README.md b/Business Rules/Incident Escalation and Notifications/README.md new file mode 100644 index 0000000000..f4bb88ab47 --- /dev/null +++ b/Business Rules/Incident Escalation and Notifications/README.md @@ -0,0 +1,10 @@ +# 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. From 3ab4ece7cb1aee9706525800c76d09a185097278 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:30:03 +0530 Subject: [PATCH 4/8] Update incident_escalation.js --- .../incident_escalation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Business Rules/Incident Escalation and Notifications/incident_escalation.js b/Business Rules/Incident Escalation and Notifications/incident_escalation.js index f51cc61f5a..e55404eed8 100644 --- a/Business Rules/Incident Escalation and Notifications/incident_escalation.js +++ b/Business Rules/Incident Escalation and Notifications/incident_escalation.js @@ -1,3 +1,6 @@ +//Escalate incidents based on priority and time elapsed since creation. +//Notify the assigned group and incident manager. + // Business Rule: Complex Incident Escalation (function executeRule(current, previous /*null when async*/) { // Constants From 79fb4d3cbb613b0223306642635f9f0fe0dad620 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:36:39 +0530 Subject: [PATCH 5/8] Update README.md --- Business Rules/Incident Escalation and Notifications/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Business Rules/Incident Escalation and Notifications/README.md b/Business Rules/Incident Escalation and Notifications/README.md index f4bb88ab47..8947833c70 100644 --- a/Business Rules/Incident Escalation and Notifications/README.md +++ b/Business Rules/Incident Escalation and Notifications/README.md @@ -1,7 +1,7 @@ # 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. +This code 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. From 49f5f29445283870bdd1607cba92324945ef20fe Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:40:33 +0530 Subject: [PATCH 6/8] Delete Business Rules/ConditionsandScriptLogic --- Business Rules/ConditionsandScriptLogic | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Business Rules/ConditionsandScriptLogic diff --git a/Business Rules/ConditionsandScriptLogic b/Business Rules/ConditionsandScriptLogic deleted file mode 100644 index 1eb4e31abe..0000000000 --- a/Business Rules/ConditionsandScriptLogic +++ /dev/null @@ -1,10 +0,0 @@ -// Check if the Business Rule has a condition -if (!current.condition) { - gs.addErrorMessage('Business Rule without condition: ' + current.name); -} - -// Check for inefficient script logic (example: GlideRecord queries inside loops) -var script = current.script.toString(); -if (script.includes('while') && script.includes('new GlideRecord')) { - gs.addErrorMessage('Potential inefficient GlideRecord usage in Business Rule: ' + current.name); -} From 987e23a711a0898abf52c90faab93b0687d8e6a3 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:42:57 +0530 Subject: [PATCH 7/8] Delete Business Rules/Incident Escalation and Notifications/incident_escalation.js --- .../incident_escalation.js | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 Business Rules/Incident Escalation and Notifications/incident_escalation.js diff --git a/Business Rules/Incident Escalation and Notifications/incident_escalation.js b/Business Rules/Incident Escalation and Notifications/incident_escalation.js deleted file mode 100644 index e55404eed8..0000000000 --- a/Business Rules/Incident Escalation and Notifications/incident_escalation.js +++ /dev/null @@ -1,36 +0,0 @@ -//Escalate incidents based on priority and time elapsed since creation. -//Notify the assigned group and incident manager. - -// Business Rule: Complex Incident Escalation -(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.sys_created_on, gs.nowDateTime(), true); - - // Check if the incident is unresolved and time elapsed exceeds the escalation threshold - if (current.state != 'Resolved' && timeElapsed > ESCALATION_THRESHOLD_HOURS * 3600) { - // Escalate the incident by updating its priority - current.priority = Math.max(1, current.priority - 1); - gs.addInfoMessage('Incident priority has been escalated.'); - - // Notify the assigned group and incident manager - var assignedGroup = current.assignment_group.getDisplayValue(); - var incidentManager = current.u_incident_manager.getDisplayValue(); - 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.assignment_group.setDisplayValue(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.priority + ', Assigned Group: ' + assignedGroup + ', Incident Manager: ' + incidentManager; - gs.log(logMessage, 'ComplexIncidentEscalation'); - } -})(current, previous); From 10be96dc0cdf702c181e68384935f913e56ac999 Mon Sep 17 00:00:00 2001 From: MANCHALA YASWANTH <71426465+MYaswanth28@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:44:35 +0530 Subject: [PATCH 8/8] Delete Business Rules/Incident Escalation and Notifications/README.md --- .../Incident Escalation and Notifications/README.md | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Business Rules/Incident Escalation and Notifications/README.md diff --git a/Business Rules/Incident Escalation and Notifications/README.md b/Business Rules/Incident Escalation and Notifications/README.md deleted file mode 100644 index 8947833c70..0000000000 --- a/Business Rules/Incident Escalation and Notifications/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Complex Incident Escalation and Notification - -## Description -This code 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.