Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);
Loading