Skip to content

Commit 098fd89

Browse files
authored
Reassign tasks when assigned user is inactive (#1967)
* script.js * readme.md * Update script.js
1 parent 3d8b145 commit 098fd89

File tree

2 files changed

+31
-0
lines changed
  • Server-Side Components/Business Rules/Reassign Tasks When Assigned User is Inactive

2 files changed

+31
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Purpose
2+
Automatically reassigns tasks or incidents when the currently assigned user becomes inactive.
3+
This ensures that no work item stays unattended due to user deactivation, termination, or role changes, maintaining operational continuity and SLA compliance.
4+
## Tables Applicable:
5+
Any task-based table, such as incident, problem, change_request, etc.
6+
## Implementation Details
7+
Table: sys_user
8+
Trigger: Business Rule – After Update
9+
Condition: current.active == false && previous.active == true
10+
Purpose: Trigger logic only when a user becomes inactive.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(function executeRule(current, previous) {
2+
3+
// Trigger only when user becomes inactive
4+
if (previous.active && !current.active) {
5+
gs.info("User " + current.name + " became inactive. Reassigning their open tasks...");
6+
7+
// GlideRecord to find open tasks assigned to the user
8+
var taskGR = new GlideRecord('task');
9+
taskGR.addQuery('assigned_to', current.sys_id);
10+
taskGR.addQuery('state', '!=', 3); // Exclude closed tasks
11+
taskGR.query();
12+
13+
while (taskGR.next()) {
14+
// Add a work note to notify assignment group
15+
taskGR.work_notes = "Assigned user '" + current.name + "' is inactive. Please take necessary action.";
16+
taskGR.update();
17+
18+
gs.info("Work note added to task " + taskGR.number);
19+
}
20+
21+
})(current, previous);

0 commit comments

Comments
 (0)