Skip to content
Merged
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,10 @@
## Purpose
Automatically reassigns tasks or incidents when the currently assigned user becomes inactive.
This ensures that no work item stays unattended due to user deactivation, termination, or role changes, maintaining operational continuity and SLA compliance.
## Tables Applicable:
Any task-based table, such as incident, problem, change_request, etc.
## Implementation Details
Table: sys_user
Trigger: Business Rule – After Update
Condition: current.active == false && previous.active == true
Purpose: Trigger logic only when a user becomes inactive.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(function executeRule(current, previous) {

// Trigger only when user becomes inactive
if (previous.active && !current.active) {
gs.info("User " + current.name + " became inactive. Reassigning their open tasks...");

// GlideRecord to find open tasks assigned to the user
var taskGR = new GlideRecord('task');
taskGR.addQuery('assigned_to', current.sys_id);
taskGR.addQuery('state', '!=', 3); // Exclude closed tasks
taskGR.query();

while (taskGR.next()) {
// Add a work note to notify assignment group
taskGR.work_notes = "Assigned user '" + current.name + "' is inactive. Please take necessary action.";
taskGR.update();

gs.info("Work note added to task " + taskGR.number);
}

})(current, previous);
Loading