BLOG - Work Order Tasks Automatically Getting Unassigned When Another Task Moves to Work In Progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Issue Summary
In ServiceNow Field Service Management (FSM), when multiple Work Order Tasks share the same Assigned To agent and the same scheduled date/time, moving one task to Work In Progress (WIP) can cause the system to automatically unassign the remaining tasks.
🔁 What Triggers This?
When a field agent starts a task (moves it to "Work In Progress"), the system runs a background check called shiftAgentTasksToRight.
Think of it like this:
"John just started Task 1 and it's taking longer than planned. Can he still finish all his other tasks today before his shift ends?"
If the answer is NO — the system starts unassigning tasks automatically.
📋 The 3 Situations Where Unassignment Happens
🔴 Situation 1 — "John is Already Working Overtime"
Code: agentScheduleEndMS == -1 → calls processCurrentTaskOverTime
What this means:
John's shift was supposed to end at 5 PM. But he started his current task so late that he's already past 5 PM — he's already in overtime before even finishing this task.
What the system does:
- It says: "John is overloaded. Clear ALL his remaining tasks for the day."
- Every task still assigned to John (that hasn't started yet) gets unassigned
Protection: If even ONE of those remaining tasks is already In Progress or locked, the system does nothing — it won't touch anyone.
🔴 Situation 2 — "There's Not Enough Time Left in John's Day"
Code: shouldMove: false, reason = "Too small" or "Over time" → calls unAssignTasks
What this means:
John finishes his current task at 4:30 PM. His shift ends at 5 PM. He still has 3 tasks left — but they need 3 hours of work. There's only 30 minutes left.
What the system does:
- It tries to fit the next task into the remaining time
- It checks: "Is the gap big enough?" → Too small → Can't fit
- Or it checks: "Will this push past end of shift?" → Overtime not allowed → Can't fit
- Result: That task and all tasks after it get unassigned
Protection: Same rule — if any of those tasks is already In Progress or locked, the system does nothing.
🔴 Situation 3 — "Only One Task Can Squeeze In, But the Rest Can't"
Code: shouldMove: true + reason = "Over time" → moves one task, then calls unAssignTasks for the rest
What this means:
John has 4 tasks left. After checking, the system finds that Task 2 can just barely fit — but it will go slightly into overtime. Tasks 3 and 4 definitely won't fit at all.
What the system does:
- It keeps Task 2 (moves it slightly into overtime, if overtime is allowed)
- It unassigns Task 3 and Task 4 — they have no place in John's day anymore
Protection: Again — if Task 3 or 4 is In Progress or locked, the system leaves everything untouched.
🔒 What Protects a Task from Being Unassigned?
The system checks every task before unassigning. If it finds even one task that is:
Protection What it means
| State = Work In Progress (WIP) | John already started this task — don't touch it |
| Schedule Lock = ON | A dispatcher manually locked this task — don't touch it |
If either condition exists on any task in the list → no tasks get unassigned at all.
🗺️ How the Code Flows — Step by Step (Simply)
John moves Task 1 → WIP
↓
System runs: shiftAgentTasksToRight
↓
Step 1: Calculate when Task 1 will finish
↓
Step 2: Is John already in overtime?
YES → Unassign ALL remaining tasks (if none are WIP/locked)
NO → Continue ↓
↓
Step 3: Loop through John's remaining tasks one by one:
→ Can this task fit in John's remaining time?
YES → Keep it, note the new time, move to next task
(If it fits only in overtime → keep it, then STOP & unassign the rest)
NO → Unassign this task AND all tasks after it
↓
Step 4: Actually save the new times / unassignments to the database💡 Real-Life Analogy
Think of it like a delivery driver's route:
- The driver (John) has 5 deliveries planned for the day
- He gets stuck in traffic on Delivery 1 and starts it late
- His supervisor (the system) recalculates: "Can he make all 5 deliveries before the warehouse closes?"
- If not — the supervisor removes him from deliveries 4 and 5 so someone else can pick them up
- But if delivery 3 is already at the customer's door (In Progress) — the supervisor doesn't touch anything and waits
✅ Simple Summary
What's Happening System Response
| Agent already in overtime | Unassign ALL remaining tasks |
| Not enough time for next task | Unassign that task + all after it |
| Only one task fits in overtime | Keep that one, unassign the rest |
| Any task is WIP or Locked | Do nothing — leave everything as-is |
