Sub topic 15
Design guidelines for a maintainable routing setup
This chapter assumes you have read the earlier chapters on queues, assignment rules, business hours, escalation rules, testing, monitoring, Omni-Channel, and entitlements. You should be comfortable with Setup, list views, and reading short SOQL and Apex snippets. The goal here is to turn those separate features into a setup that stays understandable after a year of changes by several administrators.
Why routing setups decay
A routing setup rarely fails on day one. It decays as people add one more rule entry for one more team, one more queue for one more region, and one more escalation for one more customer. Typical symptoms are:
- Nobody can say why a case landed in a given queue.
- Queues exist that no one monitors, so cases sit unnoticed.
- Rule entries overlap, so order decides the outcome and edits break unrelated cases.
- Escalations fire for the wrong cases, or never fire, because business hours or criteria drifted.
The guidelines below target these failure modes. Each one trades a little up-front effort for easier changes later.
Choose the right mechanism first
Pick the lightest mechanism that meets the requirement. A heavier one adds configuration you must maintain.
| Requirement | Best fit | Why |
|---|---|---|
| Send cases to a team based on fields such as Origin, Type, or Priority | Assignment rules with queues | Simple, declarative, and visible in Setup |
| Route to the least busy or best-skilled available agent | Omni-Channel | Assignment rules cannot see agent capacity or presence |
| Contractual response and resolution times that vary by customer | Entitlements and milestones | Timing comes from the customer's entitlement, not a single global rule |
| Flat "if still open after N hours, reassign or notify" | Escalation rules | Age-based, one set of rules for the org |
| Routing that depends on data in other objects or external systems | Apex or Flow that sets OwnerId | Rule criteria only see the case and a few related fields |
You can combine them. A common pattern is assignment rules to place a case in a queue, Omni-Channel to hand it to an agent from that queue, and milestones to enforce the SLA. Avoid using two mechanisms for the same decision. If both an escalation rule and a milestone reassign the same case, you will spend hours working out which one acted.
Design queues around work, not around people
A queue should represent a pool of work that a team can pick up. Follow these rules.
- Name queues by function. Use
Tier2_SupportorBilling_EMEA, notMaria_Backup. People change roles, and functions last longer. - Keep the API name stable. Apex and flows often look up queues by
DeveloperName, as in the earlier Group query. Renaming the label is safe. Changing the developer name is not, because it breaks code that looks it up. - Limit the number of queues. Each queue needs members, a monitor, and a place in the rules. If two queues are always worked by the same people, merge them.
- Use public groups or roles for membership. Adding a group to a queue means a team change is made in one place rather than in every queue.
- Define a catch-all queue. Give the last assignment rule entry, with no criteria, a queue such as
Unassigned_Triage. Cases that match nothing otherwise go to the default case owner, and that often hides them. - Check queue support for Case. A queue only accepts cases if Case is a supported object on that queue.
Keep assignment rules short and ordered on purpose
Only one assignment rule is active at a time, and its entries are evaluated in order. The first entry that matches wins. That makes the order a design decision.
- Put the most specific entries first and the general ones last.
- Keep entries mutually understandable. If you can describe an entry in one sentence, it is probably fine. If it needs a paragraph, split it or move the logic to a field.
- Prefer a routing field over long criteria. For example, a picklist
Routing_Category__cset by a form, a flow, or Email-to-Case routing lets the rule entry check one field instead of five. - Add the entry number to your documentation, and renumber carefully. Reordering entries changes behavior without changing any entry.
- Set "Do not reassign owner" deliberately on entries where a manual owner must be kept.
Remember that assignment rules run only when triggered. Web-to-Case and Email-to-Case can apply the default rule, the new case form has a checkbox, and Apex needs DMLOptions, as shown in the earlier snippet. Document which channels trigger the rule so a missing owner is easier to diagnose.
Make escalation predictable
Escalation rules act on cases that stay open. They are easy to misconfigure because their effect depends on time.
- Always attach business hours. Escalation entries can use the case's business hours or a specific set. Choose explicitly. If a team works Monday to Friday, a 4-hour escalation raised Friday at 4 pm should wait until Monday morning.
- Stack age in steps. Use several escalation actions in one entry, for example notify the owner at 2 hours, reassign to a queue at 4, and notify the manager at 8. Each step should have a distinct purpose.
- Notify before reassigning. A notification gives the owner a chance to act. Reassigning first removes work from a person who may already be on it.
- Keep one active escalation rule. As with assignment rules, only one escalation rule is active. Document what it covers.
- Escalate to a queue or a role-based target, not to a named person. A named person may be on leave or may have left.
- Know the stopping conditions. Escalation checks cases against entry criteria and the age since creation or last modification, as you set it. Closing the case stops it. Edits that reset the "last modified" clock can postpone escalation, so choose the age basis carefully.
// Reports how many open cases each queue holds, to confirm no queue is silently growing.
Map<String, Integer> openByQueue = new Map<String, Integer>();
for (AggregateResult ar : [
SELECT Owner.Name ownerName, COUNT(Id) total
FROM Case
WHERE Owner.Type = 'Queue' AND IsClosed = false
GROUP BY Owner.Name
]) {
openByQueue.put((String) ar.get('ownerName'), (Integer) ar.get('total'));
}
System.debug(openByQueue);Run a check like this on a schedule, or build the equivalent report, and review it weekly.
Document the setup
Setup screens show what a rule does, but not why. Keep a short routing document, in a wiki or a Salesforce knowledge article, with:
- A table of queues: name, purpose, members, and owner.
- The ordered assignment rule entries with the reason for each.
- The escalation entries with business hours, age, and action.
- The channels and what triggers the rule for each.
- A change log with date, author, and reason.
Use the Description field on queues, rule entries, and business hours where Setup provides one. That puts the reason next to the configuration.
Change safely
- Build and test in a sandbox. Include cases from every channel.
- Use a test case for each assignment entry, and a case old enough to trigger each escalation step. Sandbox business hours and time zones must match production.
- Deploy with change sets or metadata deployments where possible. Queues, assignment rules, escalation rules, and business hours are all metadata.
- Release at a quiet time. Activating a new assignment rule affects only new or re-triggered cases, but a new active escalation rule can act on existing open cases that match.
- Watch the queue and escalation views for a day after release.
- Keep the previous rule's exported metadata so you can roll back.
Common anti-patterns
- A queue per person. It duplicates the user record and defeats pooled work.
- Hard-coded Ids in Apex. Queue Ids differ between sandbox and production. Query by
DeveloperName. - Several automations setting OwnerId. Triggers, flows, and assignment rules may all write the owner. Pick one owner of the decision.
- No monitoring. A queue nobody opens is a place where cases wait. Pair every queue with a list view or report and a named reviewer.
- Escalating everything. If most cases escalate, the escalation signal carries no information. Tune the age or fix the capacity problem.
Exercise
A team has three queues, Billing_US, Billing_EU, and Billing_APAC. The same eight agents work all of them, and cases are often left in the wrong queue. Using this chapter's guidelines, what would you change, and what would you add so that unmatched cases are never lost?
Show answer
Merge the three queues into one Billing queue, or keep one queue and add a routing field such as Region__c for reporting, since the same people work all of them. Fewer queues means fewer misrouted cases and less to monitor. Add a final assignment rule entry with no criteria that sends unmatched cases to a catch-all queue such as Unassigned_Triage. Give that queue a list view and a named reviewer.
Exercise
An escalation rule reassigns a case to Tier2_Support after 4 hours. A case opened at 4 pm on Friday escalates at 8 pm Friday, when no one is working. What setting should you check, and what other change makes the process kinder to owners?
Show answer
Check the business hours on the escalation rule entry. Set the entry to use business hours that match the team's working week, so the 4 hours count only within working time and the case escalates Monday morning. Also add a notification step to the owner before the reassignment, so the owner can act before the case moves.