# How do Territory Assignment Rules automate complex enterprise account segmentation?

**Topic:** Sales Cloud · **Difficulty:** Medium · **Tags:** Sales Cloud, Territory Management, Assignment Rules

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-territory-assignment-rules-automate-complex-enterprise-account-segmentation

## Answer

**Basics:** A territory is a segment of accounts (by geography, industry, size) that a set of reps owns, independent of the role hierarchy. Assignment rules remove manual assignment: define "Billing Country = Germany AND Industry = Manufacturing" on a territory and any account meeting it is assigned. The same account can sit in several territories (for example a geographic and a named-account territory).

**How it works:**
1. Setup > Territory Settings: enable Enterprise Territory Management; set default access levels.
2. Create a Territory Model (Planning state), Territory Types, and the hierarchy.
3. Per territory, add Assignment Rules (field, operator, value; rules can inherit from the parent) and assign users.
4. Run rules (Run Rules button) and review; then set the model to Active.
5. After activation rules can run on create/edit if "Evaluate this account against territory rules on save" is selected in the Account page layout/ settings, and in the API via Database.DMLOptions.assignmentRuleHeader.useDefaultRule.

**Advanced / deep dive:** Models go Planning > Active > Archived; only one model is active, so you can build next year's structure in Planning and cut over later. Rules apply to Accounts only; opportunities are assigned to a territory either by Salesforce's default (inherit from the account when only one territory matches) or by a custom Apex class implementing TerritoryMgmt.OpportunityTerritoryAssignmentFilter (can choose one territory when several match). Manual assignments are preserved and can be excluded from rule runs. Account access is granted to the territory users through the territory's access settings, and Customizable Forecasts can roll up by territory. Underlying objects: Territory2Model, Territory2, UserTerritory2Association, ObjectTerritory2Association (with AssociationCause = 'Territory2AssignmentRule' vs 'Territory2Manual'). Original Territory Management (legacy) is unsupported/retired, and the legacy model is not the same as ETM. Territory limits depend on edition; verify in the current limits doc. Large rule sets over millions of accounts run asynchronously and can take hours.

**Code / config example:**
```sql
-- Which accounts are in a territory and why
SELECT ObjectId, Territory2.Name, AssociationCause
FROM ObjectTerritory2Association
WHERE Territory2Id = :terrId
```

**Hidden gotchas & must-remember points:**
- Rules target Accounts only; opportunity assignment needs the filter class for ambiguity.
- Rules do not fire retroactively; run them after changes.
- Only the Active model affects visibility and forecasts.
- Rule-based and manual assignments are tracked separately via AssociationCause.
- Plan field data quality; blank or misspelled Billing State values mean misplaced accounts.
- Sandboxes copy models, but activation changes in production recalculate access.

**Best practice:** Design territories from clean, standardized fields (use picklists or normalized values) and test the model in Planning before activating.

---
Source: ForceChallenges · last updated 2026-11-02
