Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/assignment-rules

assignment-rules

Verified

Use this skill when configuring or troubleshooting Lead or Case assignment rules in Salesforce: creating rule entries, setting filter criteria, assigning records to users or queues, understanding when rules run, and implementing round-robin patterns with Apex. Trigger keywords: lead assignment, case assignment, assignment rule, queue assignment, auto-assign. NOT for creating the queue or public group a rule routes into — use admin/queues-and-public-groups. NOT for Omni-Channel or skills-based routing — use admin/omni-channel-routing-setup. NOT for approval routing — use admin/approval-processes.

references/well-architected.md

View on GitHub
# Well-Architected Notes — Assignment Rules

## Relevant Pillars

- **Operational Excellence** — Assignment rules are a core operational mechanism. A well-configured rule reduces manual ownership decisions, ensures consistent routing, and makes queue workloads visible to managers. Poorly ordered rule entries or missing catch-all entries create operational noise (mis-routed records, late response).
- **Reliability** — Rules that depend on API callers passing the correct header create a reliability risk: one missed header means records silently bypass routing. Design for reliability by auditing integration touchpoints and making header inclusion a code review requirement.
- **Scalability** — Native assignment rules scale to 3,000 entries per rule without code. For round-robin or capacity-based routing at volume, Omni-Channel is the scalable choice over Apex triggers that may hit CPU limits under bulk insert.

## Architectural Tradeoffs

**Declarative vs Apex routing:** Assignment rules are the correct first choice for criteria-based routing — they require no deployment risk, no testing infrastructure, and are maintainable by admins. Apex is only warranted when the routing logic cannot be expressed as field-value criteria (e.g., true round-robin, machine-learning-based scoring) or when the assignment must react to external service responses.

**Queue vs direct user assignment:** Queue assignment is more resilient to staff changes. Adding or removing a user from a queue does not require changing the assignment rule. Direct user assignment creates a single point of failure if the assigned user goes on leave — every rule entry targeting that user must be updated. Prefer queue assignment with Omni-Channel for flexible capacity management.

**Assignment rules vs Flow:** Record-triggered Flows can also set OwnerId during before-save execution, and they run before assignment rules in the order of operations. If a Flow sets OwnerId and the assignment rule also runs, the assignment rule's result will override the Flow's OwnerId set in before-save — unless the user/API caller does not opt in to the rule. This interaction must be explicitly tested.

## Anti-Patterns

1. **Multiple overlapping assignment mechanisms without explicit priority** — Using both a before-save Flow that sets OwnerId and an active assignment rule on the same object creates unpredictable ownership. The rule fires after before-save, so the rule result typically wins. Document and test which mechanism is authoritative.
2. **Targeting individual users instead of queues for team routing** — Hard-coding individual user IDs in rule entries creates maintenance overhead. Every time a rep changes territory, quits, or goes on leave, an admin must update the assignment rule. Queues with Omni-Channel or queue + human acceptance provide resilience.
3. **No catch-all rule entry** — Rules with only specific criteria entries will not match every record. Unmatched records go to the Default Lead Owner or retain the API user as owner — silently. Always add a final entry with no criteria as a catch-all to a known default queue.

## Official Sources Used

- Salesforce Help: Set Up Lead Assignment Rules — https://help.salesforce.com/s/articleView?id=sf.customizestandard_leadrules.htm&type=5
- Salesforce Help: Set Up Case Assignment Rules — https://help.salesforce.com/s/articleView?id=sf.cases_assignment.htm&type=5
- Metadata API Developer Guide: AssignmentRules Metadata Type — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_assignmentrule.htm
- Object Reference: AssignmentRule sObject — https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_assignmentrule.htm
- Metadata API Developer Guide: AutoResponseRules Metadata Type — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_autoresponserules.htm
- Metadata API Developer Guide: EscalationRules Metadata Type — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_escalationrules.htm
- Metadata API Developer Guide (PDF, v62, used for the field tables and sample definitions in references/metadata-examples.md) — https://resources.docs.salesforce.com/262/latest/en-us/sfdc/pdf/api_meta.pdf
- Object Reference (PDF, v62): AssignmentRule is read-only, queryable, and its Id feeds AssignmentRuleHeader / Bulk API assignment — https://resources.docs.salesforce.com/262/latest/en-us/sfdc/pdf/object_reference.pdf
- Apex Reference Guide: Database.DMLOptions Class — https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Database_DMLOptions.htm
- Salesforce Help: Create a Sandbox (usernames and email deliverability after refresh) — https://help.salesforce.com/s/articleView?id=sf.data_sandbox_create.htm
- Salesforce Well-Architected Overview — https://architect.salesforce.com/docs/architect/well-architected/guide/overview.html
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall