Sub topic 10
Testing and Troubleshooting Routing and Escalation
This chapter assumes you can create queues, build assignment rules with ordered rule entries, and define an escalation rule with business hours. Here you check that those pieces work and find the cause when they don't.
Test with a controlled case
Test in a sandbox or with clearly labeled test records. Each test should change one thing, so a failure points to one cause.
- Create a case whose field values match exactly one rule entry.
- Note the owner, the status, and the time of creation.
- Compare the result with what you expected.
Assignment rules run only when a case is created or edited and the "Assign using active assignment rule" option is selected. They do not run on every save.
Test assignment rules
Check these points in order.
- The rule is active. Only one case assignment rule can be active at a time.
- Rule entries are evaluated in sort order. The first entry whose criteria match wins, and later entries are skipped.
- The assigned user or queue is valid. A queue must list Case as a supported object.
- The case was created through a path that runs the rule.
Different channels treat the rule differently. Web-to-Case and Email-to-Case apply the active rule by default. Manual entry applies it only if the box is checked. Apex applies it only if you set DMLOptions, as shown in the Apex chapter.
Case c = [SELECT Id FROM Case WHERE Subject = 'Routing test 1' LIMIT 1];
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
c.setOptions(dmo);
update c;
Case result = [SELECT Owner.Name, Owner.Type FROM Case WHERE Id = :c.Id];
System.debug(result.Owner.Name + ' (' + result.Owner.Type + ')');If the case has no matching entry, it goes to the default case owner, which is set in Support Settings. An unexpected owner is often this default.
Test escalation rules
Escalation is time-based, so you can't see the result at creation. Escalation rules check cases on a schedule, not the instant the age threshold passes. Expect a delay of up to about 30 minutes. Plan test cases with short ages, such as 60 minutes, in a sandbox.
Verify with the escalated-case query from the monitoring chapter:
SELECT Id, CaseNumber, Subject, Priority, Owner.Name, CreatedDate
FROM Case
WHERE IsEscalated = true AND IsClosed = false
ORDER BY CreatedDate ASCCommon problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Case stays with the creating user | Assignment rule did not run | Select the assignment option, or set `DMLOptions` in Apex |
| Case goes to the wrong queue | An earlier rule entry matches first | Reorder entries, or tighten the criteria |
| Case goes to the default owner | No entry matched | Fix the criteria or add a catch-all entry last |
| Case never escalates | Rule inactive, case closed, or criteria not met | Activate the rule and check the entry criteria |
| Escalation is late | Business hours or the check interval | Review the business hours on the entry |
| Escalation happens but nobody is told | Notification template or recipient missing | Check the action's user and email template |
| Case reassigns again after escalation | Entry reassigns to a user or queue that routes it elsewhere | Review the action's target |
Debug a routing path
Work from the case backward.
Also review the case history and the debug logs for flows or triggers that change OwnerId after the rule runs. Automation that fires later overrides the assignment.
Exercise
A case created through Apex stays owned by the integration user, although a matching assignment rule entry exists and the rule is active. What is the most likely cause, and how do you fix it?
Show answer
Apex inserts do not run assignment rules by default. Create a Database.DMLOptions object, set assignmentRuleHeader.useDefaultRule to true, call setOptions on the case, and then insert it.
Exercise
An escalation rule entry is set to 2 hours and uses business hours that end at 5 pm. A case is created at 4:30 pm Friday. Why is it not escalated by 7 pm Friday?
Show answer
The age counts only business hours. About 30 minutes pass on Friday, so the 2-hour threshold is reached on the next business day, and the rule's periodic check can add a further delay.