From e4e86a4a08cb8fb381e3f4f74268a85cdd242b04 Mon Sep 17 00:00:00 2001 From: Shankha Bhattacharya <48099339+iamshankha@users.noreply.github.com> Date: Fri, 10 Oct 2025 00:00:13 +0530 Subject: [PATCH 1/2] Create Smart_Incident_Assignment.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Smart Incident Assignment – Auto-Assign Incident to Idle Members This server-side solution automatically assigns incidents containing keywords like “disaster” or “emergency” to idle members of a designated support group. It ensures workload is evenly distributed, prevents overloading specific team members, and maintains faster incident response. The assignment group is automatically set, and the system checks each member’s current open incidents before assigning, making the process efficient and balanced. --- .../Smart_Incident_Assignment.js" | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 "Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/Smart_Incident_Assignment.js" diff --git "a/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/Smart_Incident_Assignment.js" "b/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/Smart_Incident_Assignment.js" new file mode 100644 index 0000000000..976837a423 --- /dev/null +++ "b/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/Smart_Incident_Assignment.js" @@ -0,0 +1,52 @@ +// =============================================================== +// Smart Incident Assignment – Auto-Assign Incident to Idle Members +// Purpose: Automatically assign disaster/emergency incidents to idle group members to ensure workload balance. +// =============================================================== + +(function executeRule(current, previous /*null when async*/) { + + // --- Step 1: Check if short description contains disaster or emergency --- + var desc = current.short_description.toLowerCase(); + if (desc.indexOf("disaster") === -1 && desc.indexOf("emergency") === -1) { + return; // Exit if keywords are not present + } + + // --- Step 2: Define the target assignment group --- + var groupName = "Support Group"; //group name as per the requirment + var groupGR = new GlideRecord('sys_user_group'); + groupGR.addQuery('name', groupName); + groupGR.query(); + if (!groupGR.next()) return; // Exit if group not found + var groupSysId = groupGR.sys_id; + + // --- Step 3: Set the assignment group --- + current.assignment_group = groupSysId; + + // --- Step 4: Get all active members of the group --- + var memberGR = new GlideRecord('sys_user_grmember'); + memberGR.addQuery('group', groupSysId); + memberGR.query(); + + var availableMembers = []; + while (memberGR.next()) { + var userId = memberGR.user.sys_id; + + // --- Step 5: Check if user already has an open incident --- + var incidentGR = new GlideRecord('incident'); + incidentGR.addQuery('assigned_to', userId); + incidentGR.addQuery('state', '<', 7); // Excludes Closed/Resolved + incidentGR.query(); + + if (!incidentGR.hasNext()) { + availableMembers.push(userId); // Collect idle members + } + } + + // --- Step 6: Assign incident to first available idle member --- + if (availableMembers.length > 0) { + current.assigned_to = availableMembers[0]; + } else { + gs.addInfoMessage('All members of the Support Closed Group currently have active incidents.'); + } + +})(current, previous); From 6acab014cad4f617ab4fc87d2c8c487587d90b32 Mon Sep 17 00:00:00 2001 From: Shankha Bhattacharya <48099339+iamshankha@users.noreply.github.com> Date: Fri, 10 Oct 2025 00:03:36 +0530 Subject: [PATCH 2/2] Create README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🛠️ Smart Incident Assignment – Auto-Assign Incident to Idle Members 📘 Overview This Business Rule automatically assigns incidents to a predefined support group when specific keywords, such as “disaster” or “emergency”, are present in the incident’s short description. It also ensures that incidents are distributed among group members who are currently idle, maintaining workload balance across the team. 🧩 Problem Statement During critical situations, incidents tagged as disaster or emergency need immediate attention. Manually assigning these incidents can lead to: Delays in response Uneven workload distribution among support team members Errors in group assignment 💡 Solution The Auto-Assign Support Group Business Rule solves this by: Checking if the incident’s short description contains “disaster” or “emergency”. Automatically populating the Assignment Group field with Support Group. Scanning all active members of the group and checking if they already have open incidents. Assigning the incident to the first idle member to ensure balanced workload. Providing an info message if all members are currently busy, allowing fallback handling. 🚀 Benefits ✅ Ensures critical incidents are promptly assigned to the correct support team. ✅ Maintains balanced workload across team members, avoiding overloading a single user. ✅ Eliminates manual assignment errors, saving time and improving response efficiency. ✅ Enhances operational visibility and accountability in high-priority scenarios. 🛠️ Implementation Table: Incident [incident] Business Rule Type: Before Insert / Before Update Trigger: When short description contains disaster or emergency --- .../README.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/README.md" diff --git "a/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/README.md" "b/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/README.md" new file mode 100644 index 0000000000..df18c06453 --- /dev/null +++ "b/Server-Side Components/Business Rules/Smart Incident Assignment \342\200\223 Auto-Assign Incident to Idle Members/README.md" @@ -0,0 +1,48 @@ +🛠️ Smart Incident Assignment – Auto-Assign Incident to Idle Members + +📘 Overview + +This Business Rule automatically assigns incidents to a predefined support group when specific keywords, such as “disaster” or “emergency”, are present in the incident’s short description. It also ensures that incidents are distributed among group members who are currently idle, maintaining workload balance across the team. + +🧩 Problem Statement + +During critical situations, incidents tagged as disaster or emergency need immediate attention. +Manually assigning these incidents can lead to: + +Delays in response + +Uneven workload distribution among support team members + +Errors in group assignment + +💡 Solution + +The Auto-Assign Support Group Business Rule solves this by: + +Checking if the incident’s short description contains “disaster” or “emergency”. + +Automatically populating the Assignment Group field with Support Group. + +Scanning all active members of the group and checking if they already have open incidents. + +Assigning the incident to the first idle member to ensure balanced workload. + +Providing an info message if all members are currently busy, allowing fallback handling. + +🚀 Benefits + +✅ Ensures critical incidents are promptly assigned to the correct support team. + +✅ Maintains balanced workload across team members, avoiding overloading a single user. + +✅ Eliminates manual assignment errors, saving time and improving response efficiency. + +✅ Enhances operational visibility and accountability in high-priority scenarios. + +🛠️ Implementation + +Table: Incident [incident] + +Business Rule Type: Before Insert / Before Update + +Trigger: When short description contains disaster or emergency