enterprise-territory-management

Use this skill when configuring or troubleshooting Salesforce Enterprise Territory Management (ETM): territory models, territory types, territory hierarchies, account assignment rules, opportunity territory assignment, and forecast by territory. Trigger keywords: territory model, territory hierarchy, ETM, assign accounts to territories, territory forecast, territory activation. NOT for role hierarchy (use sharing-and-visibility). NOT for Legacy/Original Territory Management (pre-ETM).

Best use case

enterprise-territory-management is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when configuring or troubleshooting Salesforce Enterprise Territory Management (ETM): territory models, territory types, territory hierarchies, account assignment rules, opportunity territory assignment, and forecast by territory. Trigger keywords: territory model, territory hierarchy, ETM, assign accounts to territories, territory forecast, territory activation. NOT for role hierarchy (use sharing-and-visibility). NOT for Legacy/Original Territory Management (pre-ETM).

Teams using enterprise-territory-management should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/enterprise-territory-management/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/admin/enterprise-territory-management/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/enterprise-territory-management/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How enterprise-territory-management Compares

Feature / Agententerprise-territory-managementStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when configuring or troubleshooting Salesforce Enterprise Territory Management (ETM): territory models, territory types, territory hierarchies, account assignment rules, opportunity territory assignment, and forecast by territory. Trigger keywords: territory model, territory hierarchy, ETM, assign accounts to territories, territory forecast, territory activation. NOT for role hierarchy (use sharing-and-visibility). NOT for Legacy/Original Territory Management (pre-ETM).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Enterprise Territory Management

This skill activates when a practitioner needs to design, configure, audit, or troubleshoot Salesforce Enterprise Territory Management (ETM). It covers territory models, territory types, hierarchy design, account assignment rules, opportunity territory assignment, user territory membership, and forecast by territory.

---

## Before Starting

Gather this context before working on anything in this domain:

- **ETM must be enabled in the org.** ETM is a separate feature from Legacy (Original) Territory Management. The two cannot coexist — check Setup > Territory Management. If it shows "Enterprise Territory Management," ETM is active. Legacy Territory Management is no longer recommended.
- **Only one territory model can be Active at a time.** All other models remain in Planning or Archived state. Activating a model triggers a full background recalculation of all account assignment rules.
- **Territory forecast is separate from role hierarchy forecast.** A territory-based Forecast Type must be configured independently. Forecast hierarchy is derived from the active territory model.
- **Limits:** Up to 1,000 territories per territory model in Enterprise Edition (default). Performance/Unlimited orgs can request up to 20,000 territories per model from Salesforce Support. Only one Active model is permitted at any time.

---

## Core Concepts

### Territory Model

A territory model is the top-level container for your entire territory structure. It holds all territory types, the territory hierarchy, and all account assignment rules. A model progresses through three states:

- **Planning** — model is being designed; assignment rules can be run in preview mode without affecting live data or access.
- **Active** — model is live; assignment rules execute automatically on account create/update, and the model drives account-territory relationships, user access, and territory forecasting. Only one model can be in this state at a time.
- **Archived** — model is retired and read-only. Archiving cannot be reversed — an archived model cannot be reactivated.

Transitioning a model from Planning to Active triggers an immediate background recalculation of all assignment rules across the entire model. For large orgs this can take hours. Monitor `Territory2AlignmentLog` for completion status.

### Territory Types

Territory types are a categorization layer — they do not appear in the territory hierarchy itself, but every territory must be assigned a type. Types help you organize and report on territories by business meaning. Common examples:

- **Geographic** — regions such as "US West" or "EMEA North"
- **Named Account** — accounts owned by specific reps regardless of geography
- **Industry Overlay** — cross-functional coverage (e.g., Healthcare Overlay)

Each territory type has a **priority value** (integer). When an opportunity qualifies for multiple territories, the priority value determines which territory's assignment rule takes precedence for opportunity territory assignment.

### Territory Hierarchy

The territory hierarchy defines parent-child relationships between territories within a model. Parent territories do not automatically propagate access or rules down to child territories — each level must be explicitly configured.

For each territory, Salesforce creates two system-defined sharing groups:
- **Territory group** — direct members of that territory.
- **TerritoryAndSubordinates group** — members of that territory and all territories below it in that branch.

These groups drive record access calculations. Modifying territory membership triggers recalculation of these groups, which can add latency in large orgs.

### Account Assignment Rules

Account assignment rules are filter-based criteria that automatically assign accounts to territories based on account field values (standard or custom). Key behaviors:

- Rules can run **automatically** when an account is created or updated (controlled by the `IsActive` flag on the rule).
- Rules can also be **run manually** for a single territory or the entire model.
- If an account matches rules for multiple territories, it is assigned to **all matching territories**.
- Rules are **not retroactive** — creating or modifying a rule does not apply it to existing accounts. A manual rule run is required to backfill.
- Accounts can also be **manually assigned** to territories, independent of rules.

### Opportunity Territory Assignment (OTA)

Opportunity territory assignment links an opportunity to a territory, which is required for the opportunity to appear in territory-based forecasts. OTA can be:

- **Filter-based (automatic):** Salesforce evaluates OTA rules and assigns a territory based on account territory membership or field criteria.
- **Manual:** Users or automation can set the `Territory2Id` field on an opportunity directly.

Opportunities not assigned to any territory do not appear in territory forecasts. Monitor `Opportunity.Territory2Id` population as a key data quality metric.

### Forecast by Territory

Territory-based forecasting uses the active territory model's hierarchy as the forecast hierarchy — entirely independent of role hierarchy forecasting. You configure a **Forecast Type** in Setup > Forecasts Settings with the territory hierarchy as the source.

Important constraints:
- Forecast **sharing is not available** for territory-based forecast types, unlike role-based forecasts.
- Users must be both territory members and enabled as forecast users.
- The forecast hierarchy reflects the territory hierarchy of the active model; switching the active model restructures the forecast hierarchy.

### Access and Sharing via Territory Membership

When a user is assigned as a member of a territory, Salesforce grants them **at least Read access** to all accounts assigned to that territory, regardless of account ownership. Additional access to related Opportunities, Contacts, and Cases is controlled by `Territory2ObjSharingConfig` metadata settings.

Territory membership is always **additive** — it cannot restrict access below the org-wide default (OWD).

---

## Mode 1 — Set Up a Territory Model

Use this mode when building ETM from scratch or standing up a new territory structure.

**Step 1 — Enable ETM.** Navigate to Setup > Territory Management and enable Enterprise Territory Management. This is a one-way migration if Legacy Territory Management was previously active.

**Step 2 — Define Territory Types.** Create territory types that reflect your go-to-market segmentation. Assign priority values: lower integer = higher priority for OTA tie-breaking. Every territory must have a type.

**Step 3 — Create the Territory Model.** Create a new model in Planning state. All configuration happens while in Planning — safe to iterate on without impacting live access or forecasts.

**Step 4 — Build the Territory Hierarchy.** Create territories within the model. Assign each a territory type. Set up parent-child relationships to reflect coverage structure. Avoid hierarchies deeper than 5–6 levels — complexity increases in forecasting rollups and access management.

**Step 5 — Configure Assignment Rules.** For each territory, create account assignment rules based on field criteria (e.g., `BillingState = 'CA'`). Mark rules active for automatic execution on account create/update. Run rules in preview mode first to validate expected assignments before activating the model.

**Step 6 — Assign Users to Territories.** Add `UserTerritory2Association` records for each sales rep and manager. Assign territory roles as appropriate (e.g., Territory Manager, Account Executive). Users can belong to multiple territories.

**Step 7 — Configure Object Sharing.** Review `Territory2ObjSharingConfig` metadata to confirm Opportunity and Contact access levels are set correctly for territory members (Read/Write vs Read-Only).

**Step 8 — Activate the Model.** Activate the territory model. This triggers background assignment recalculation. Monitor `Territory2AlignmentLog`. Plan activation for off-peak windows on large orgs.

**Step 9 — Configure Forecast Type (if using territory forecasts).** In Setup > Forecasts Settings, add a Forecast Type using the territory hierarchy. Enable forecast users for territory managers.

---

## Mode 2 — Review / Audit Territory Configuration

Use this mode when auditing an existing ETM setup for correctness or scale.

**Check model state.** Query `Territory2Model` for `State` field. Confirm exactly one model has `State = 'Active'`.

**Audit territory count.** `SELECT COUNT() FROM Territory2 WHERE Territory2ModelId = '<modelId>'` — flag if count is approaching 1,000 (default limit).

**Review assignment rule coverage.** For each territory, check `AccountTerritoryAssignmentRule` records. Verify rules with expected auto-execution are marked `IsActive = true`.

**Check last rule run.** Review `Territory2AlignmentLog` for last-run timestamps. Stale timestamps indicate rules have not run since recent account data changes.

**Audit user memberships.** Query `UserTerritory2Association` to confirm expected reps are assigned to expected territories.

**Verify opportunity territory assignment.** Check `Opportunity.Territory2Id` population rate on open opportunities. Unpopulated opportunities will not appear in territory forecasts.

| Check | SOQL / Navigation | Flag If |
|---|---|---|
| Active model count | `SELECT Id, Name FROM Territory2Model WHERE State = 'Active'` | More than 1 result |
| Territory count per model | `SELECT COUNT() FROM Territory2 WHERE Territory2ModelId = :modelId` | Approaching 1,000 |
| Unassigned accounts | `SELECT COUNT() FROM Account WHERE Id NOT IN (SELECT AccountId FROM ObjectTerritory2Association)` | Unexpectedly large |
| Open opps without territory | `SELECT COUNT() FROM Opportunity WHERE Territory2Id = null AND IsClosed = false` | Unexpectedly large |

---

## Mode 3 — Troubleshoot Assignment and Sharing Issues

Use this mode when accounts are not assigned to expected territories, users lack expected access, or territory forecasts show missing data.

**Accounts not assigning automatically:**
- Confirm the assignment rule is `IsActive = true` on `AccountTerritoryAssignmentRule`.
- Confirm the territory model is in Active state (not Planning).
- Rules are not retroactive — existing accounts require a manual rule run after a new rule is created.
- Check that account field values match rule criteria exactly (case sensitivity on text/picklist values).

**Users missing access to territory accounts:**
- Confirm the user has a `UserTerritory2Association` record for the territory.
- Verify the `Territory2ObjSharingConfig` access level for the object in question.
- Remember: territory membership adds access but cannot override OWD Private if OWD is more restrictive than the territory config.

**Forecast missing accounts or opportunities:**
- Verify open opportunities have `Territory2Id` populated.
- Confirm the territory is in the Active model's hierarchy.
- Confirm the user is both a territory member and an enabled forecast user.
- Remember: territory forecast sharing is not supported — this is expected behavior, not a bug.

**Assignment ran but accounts went to wrong territory:**
- Check for multiple matching rules — accounts are assigned to all matching territories, not just one.
- Check for manual assignments that may conflict with rule-based intent.
- Review territory type priority values if OTA is producing unexpected results.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| Sales reps cover fixed geographic regions | Geographic territory type with BillingState/Country-based rules | Simple criteria, easy to maintain |
| Named account coverage alongside geo | Separate territory type for named accounts; configure as overlay | Keeps named account lists distinct from geo hierarchy |
| Testing territory redesign without disrupting live model | Create new model in Planning state; run rules in preview | Only one model can be Active; Planning state is safe |
| Backfilling accounts after new rule creation | Manually run assignment rules at model level | Rules are not retroactive by default |
| Territory-based forecasting without changing role hierarchy | Add territory Forecast Type in Forecasts Settings | ETM forecast is entirely independent of role hierarchy forecast |
| Promoting territory config to production | Deploy Territory2Model, Territory2Type, Territory2 metadata via Metadata API or change set | Territory model metadata is fully deployable |

---


## Recommended Workflow

Step-by-step instructions for an AI agent or practitioner activating this skill:

1. Gather context — confirm the org edition, relevant objects, and current configuration state
2. Review official sources — check the references in this skill's well-architected.md before making changes
3. Implement or advise — apply the patterns from Core Concepts and Common Patterns sections above
4. Validate — run the skill's checker script and verify against the Review Checklist below
5. Document — record any deviations from standard patterns and update the template if needed

---

## Review Checklist

Run through these before marking ETM setup complete:

- [ ] ETM is enabled; Legacy Territory Management is not active
- [ ] Territory model is in Active state; exactly one Active model exists
- [ ] All territories have a territory type assigned
- [ ] Account assignment rules are active and have been run against existing accounts
- [ ] User territory memberships are populated for all sales reps and managers
- [ ] Territory2ObjSharingConfig is configured for Opportunity and Contact access
- [ ] Open opportunities have Territory2Id populated for forecast accuracy
- [ ] Forecast type is configured for territory hierarchy if using territory forecasts
- [ ] Territory count is below 1,000 (or within Salesforce-approved limit)
- [ ] Metadata deployment tested in sandbox before promoting to production

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **Activating a model triggers full assignment recalculation** — The moment you move a territory model from Planning to Active, Salesforce runs all account assignment rules across the entire model as a background job. For orgs with large account volumes this can take hours. Plan activation during off-peak windows and monitor `Territory2AlignmentLog` for completion.

2. **Assignment rules are not retroactive** — Creating or modifying an assignment rule does not automatically apply it to existing accounts. You must explicitly run rules (at the territory or model level) to assign pre-existing accounts. This is the most common cause of "why didn't my accounts move to the new territory?"

3. **Archived models cannot be reactivated** — Once a territory model is Archived, it is permanently read-only. You cannot promote an Archived model back to Active. If you need to go back to a previous structure, you must recreate it. Keep work-in-progress models in Planning state, not Archived.

4. **Forecast sharing is not available for territory-based forecast types** — Unlike role-based forecasts, territory forecast types do not support the forecast sharing feature. Attempting to share territory forecast access will silently have no effect.

5. **Territory membership is additive — it cannot restrict below OWD** — If Account OWD is Public Read/Write, territory membership adds nothing. If Account OWD is Private, territory membership adds Read access. Territory access never narrows access below the OWD floor.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| Territory2Model | Container for the entire ETM configuration; deployable via Metadata API |
| Territory2Type | Classification layer for territories, including priority values for OTA |
| Territory2 | Individual territory records with parent-child hierarchy relationships |
| AccountTerritoryAssignmentRule | Filter-based rules that auto-assign accounts to territories |
| UserTerritory2Association | Links users to territories with territory roles |
| Territory2ObjSharingConfig | Controls Opportunity/Contact access level for territory members |
| Territory2AlignmentLog | Audit log of assignment rule execution jobs and completion status |

---

## Related Skills

- sharing-and-visibility — use for role hierarchy design, OWD configuration, and sharing rules; ETM access is additive to the core sharing model, not a replacement
- forecast-management — use for configuring forecast types, adjustments, and quota management once the territory forecast type is enabled

Related Skills

session-management-and-timeout

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring session timeout values, concurrent session limits, session IP locking, or logout behavior in Salesforce. Covers org-wide session settings, profile-level overrides, Connected App session policies, and Metadata API SecuritySettings deployment. NOT for OAuth token refresh flows, login IP ranges, or MFA/identity-provider configuration.

oauth-token-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when work depends on how Salesforce OAuth access and refresh tokens are issued, refreshed, rotated, revoked, or introspected for a Connected App or API client—including unexpected logouts, invalid_grant after refresh, or designing token incident response. NOT for choosing which OAuth grant or Connected App flow to implement (use integration/oauth-flows-and-connected-apps), Named Credential packaging (use integration/named-credentials-setup), or broad Connected App IP and PKCE policy hardening without a token-lifecycle angle (use security/connected-app-security-policies).

certificate-and-key-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when creating, uploading, or rotating certificates in Salesforce, configuring mutual TLS (mTLS) client authentication, managing the Java KeyStore for CA-signed certificates, diagnosing certificate expiry in JWT OAuth flows, or understanding which certificate types Salesforce supports and how to migrate them between orgs. NOT for Named Credential configuration (use named-credentials-setup skill), NOT for Shield Platform Encryption key management. Trigger keywords: Certificate and Key Management, self-signed certificate, CA-signed certificate, mutual TLS, mTLS, keystore, JKS, PKCS12, certificate rotation, certificate expiry, JWT certificate.

flexcard-state-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing FlexCard actions, conditional visibility, and state that must survive navigation, refresh, or parent/child card transitions. Triggers: 'flexcard state', 'flexcard conditional visibility', 'flexcard actions', 'flexcard refresh', 'child flexcard state'. NOT for raw LWC state or for OmniScript step state.

lwc-state-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Share state across LWCs using pub/sub, Lightning Message Service, @wire, and reactive stores. NOT for in-component reactivity.

lwc-focus-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building LWCs that need to manage focus explicitly — modal dialogs, wizard flows, dynamic inserts, list updates, error summaries, and focus after async work. Covers focus restoration, focus traps, programmatic focus across shadow DOM, and patterns for announcing changes to assistive tech. Does NOT cover general LWC a11y audit (see lwc-accessibility).

revenue-lifecycle-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when implementing or troubleshooting Salesforce Revenue Lifecycle Management (RLM) — the native Revenue Cloud product covering order-to-cash lifecycle, Dynamic Revenue Orchestrator (DRO) fulfillment plan design, asset amendments, billing schedule creation via Connect API, and invoice management. Triggers on: Dynamic Revenue Orchestrator, RLM order decomposition, DRO fulfillment swimlanes, native Revenue Cloud billing schedule, asset lifecycle management Salesforce. NOT for CPQ quoting or pricing rules (use cpq-* skills), not for the legacy Salesforce Billing managed package with blng__* objects (different product entirely), not for standard Order objects without Revenue Cloud features.

loyalty-management-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when setting up or extending Salesforce Loyalty Management — including program and currency creation, tier group design, qualifying vs. non-qualifying point currency separation, DPE batch job activation, partner loyalty configuration, and member portal setup on Experience Cloud. Triggers on: Loyalty Management setup, loyalty tier setup Salesforce, qualifying points vs redemption points, DPE batch job for loyalty, partner loyalty program Salesforce, loyalty member portal. NOT for Marketing Cloud engagement program design (separate product), not for B2B loyalty via Sales Cloud (standard opportunity, not loyalty program), not for general Experience Cloud site setup (use experience-cloud-setup skill).

scratch-org-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing, configuring, or troubleshooting scratch orgs: definition file structure, edition selection, allocation limits, Org Shape, CI automation via ScratchOrgInfo, and lifecycle management from the Dev Hub. NOT for SFDX CLI basics (use sf-cli-and-sfdx-essentials), sandbox management, or production org administration.

release-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when planning, coordinating, or governing Salesforce releases: version numbering, rollback strategy, release notes, go/no-go criteria, release calendar, and sandbox preview alignment. NOT for deployment mechanics (use devops/post-deployment-validation or devops/change-set-deployment).

pipeline-secrets-management

8
from PranavNagrecha/AwesomeSalesforceSkills

Store and inject Salesforce auth URLs, JWT keys, and API credentials into CI without leaking them. NOT for runtime secrets in Apex.

isv-license-management-and-trialforce

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when an ISV partner is wiring license enforcement, trial provisioning, or feature-flag distribution into a managed package — covers License Management App (LMA) install and registration, Lead/License object lifecycle, Trialforce Management Org (TMO) and Trialforce Source Org (TSO) split, Trialforce templates, SignupRequest API, AppExchange Checkout integration, and Feature Parameters (LmoToSubscriber / SubscriberToLmo) as the cross-org configuration channel. Triggers: 'register package with LMA', 'set up Trialforce', 'add feature parameter to managed package', 'license expired in subscriber org', 'AppExchange Checkout licensing'. NOT for general managed-package version creation, ancestor pinning, or PostInstall handler design (use managed-package-development); NOT for second-generation packaging mechanics (use second-generation-managed-packages); NOT for non-ISV experience-cloud login licensing (use experience-cloud-licensing-model).