# What is Enterprise Territory Management in Salesforce Sales Cloud, and how do territory models and assignment rules automate account assignments?

**Topic:** Sales Cloud · **Difficulty:** Hard · **Asked at:** PwC, Deloitte Digital, Cognizant · **Tags:** Sales Cloud, Territory Management, Account Assignment

Read it on the site: https://www.forcechallenges.com/interview-questions/what-is-enterprise-territory-management-and-how-does-it-automate-account-assignments

## Answer

**Enterprise Territory Management (ETM)** is Salesforce's feature for organising accounts into **territories**, usually by geography, industry, account size or product, and giving the right sales users access to them. It replaces manual account sharing with **rules**, so assignments stay correct as data changes.

**Core building blocks**
- **Territory model**: a full design of your territories. It has a state: Planning, Active or Archived. Only **one model is active** at a time, so you can design and test a new model in Planning without disturbing the live one.
- **Territory types**: templates (for example Named Accounts or Geography) that define priority and shared settings.
- **Territory hierarchy**: parent and child territories (for example Global \u2192 EMEA \u2192 UK).
- **Users**: sales reps are assigned to territories, with a territory role.
- **Assignment rules**: filter criteria on the account, such as `BillingCountry = 'India'` and `AnnualRevenue > 1000000`. Rules can be inherited by child territories.

**How account assignment is automated**
1. Admins create assignment rules for each territory.
2. When an account is created or edited, **active rules evaluate it**. Admins can also choose **Run Rules** to re-evaluate everything.
3. Matching accounts are linked to the territory (an **ObjectTerritory2Association** record), and users in that territory get access through territory sharing.
4. Accounts can also be **assigned manually**, and manual assignments are kept when rules run.
5. An account can belong to **several territories**, which suits overlapping geographies or named accounts.

**Opportunities and forecasts**
- An opportunity can be linked to a territory (`Territory2Id`). When the account is in one territory, the opportunity normally follows it.
- If the account is in **several territories**, an **Apex opportunity territory assignment filter** decides which one to use.
- **Collaborative Forecasts** can use the territory hierarchy, so forecasts roll up by territory instead of role.

**See why an account is in a territory**

```soql
SELECT ObjectId, Territory2.Name, AssociationCause
FROM ObjectTerritory2Association
WHERE ObjectId = :accountId
```
`AssociationCause` shows whether it came from a rule or a manual assignment.

**Apex filter for opportunities**

```apex
global class OppTerritoryFilter implements TerritoryMgmt.OpportunityTerritoryAssignmentFilter {
    global Map<Id, Id> getOpportunityTerritory(List<Id> opportunityIds) {
        Map<Id, Id> oppToTerritory = new Map<Id, Id>();
        Map<Id, Id> oppToAccount = new Map<Id, Id>();
        for (Opportunity o : [SELECT Id, AccountId FROM Opportunity WHERE Id IN :opportunityIds]) {
            oppToAccount.put(o.Id, o.AccountId);
        }
        Map<Id, Id> accountToTerritory = new Map<Id, Id>();
        for (ObjectTerritory2Association a : [
            SELECT ObjectId, Territory2Id FROM ObjectTerritory2Association
            WHERE ObjectId IN :oppToAccount.values()
        ]) {
            if (!accountToTerritory.containsKey(a.ObjectId)) {
                accountToTerritory.put(a.ObjectId, a.Territory2Id); // first match wins
            }
        }
        for (Id oppId : oppToAccount.keySet()) {
            Id terrId = accountToTerritory.get(oppToAccount.get(oppId));
            if (terrId != null) { oppToTerritory.put(oppId, terrId); }
        }
        return oppToTerritory;
    }
}
```
Replace the "first match wins" line with your own business rule, such as the highest-priority territory.

**Best practices**
- Build and test the new model in **Planning**, then activate it.
- Keep rules simple, using indexed or low-cardinality fields.
- Schedule large rule runs outside business hours, because they touch many records and sharing.
- Document who owns each territory and review them regularly.

**Interview tip:** the key idea is *model \u2192 territory \u2192 rule \u2192 account association \u2192 sharing and forecast rollup*.

---
Source: ForceChallenges · last updated 2026-10-31
