Loading

Managing Salesforce Territory Assignment Rules Using ZIP Codes in Enterprise Territory Management

Fecha de publicación: Aug 18, 2026
Descripción

Territory Management assignments can be based on ZIP Code. Original Territory Management and Enterprise Territory Management both support territory definition and assignment using ZIP Code. For assignment rules involving ZIP Code, you can use a range with the Is Greater than and Is Less than operators, patterns with the Contains operator, or enumerated ZIP Codes with the Equals operator.

Note: When using the enumeration method, be aware that the number of ZIP Codes that can be included is subject to the 1,048 character limit of SOQL (Salesforce Object Query Language). Below are three approaches for managing territory assignment involving large amounts of ZIP Codes.

Solución

Approach 1: Data Loader with Spreadsheet Definitions

Territory assignment rules are accessible through the API, so you could maintain the definitions in Excel spreadsheets as you're presently doing. Any time you need to update, run an update via Data Loader based on your changes in the spreadsheet, eliminating the extra step of cutting and pasting.

Approach 2: Custom Object with Cross-Object Formula Field

Another efficient approach for managing a large volume of ZIP Codes is to create a custom object that contains ZIP Code definitions. Each entry in the custom object maps a ZIP Code against a territory name. Create a lookup relationship between the Account and the custom object that represents a custom ZIP Code field on the Account. Then create a cross-object formula on the Account that references the territory name on the custom object for the corresponding ZIP Code selected, so every time a user fills out the custom ZIP Code field, the cross-object formula field is automatically populated with the territory name. Instead of defining your territory rules based on ZIP Codes, write your rules based on the territory name in the formula field.

Advantages and considerations of this approach:

  • Your territory assignment rules are much more concise.
  • You have a table-driven approach to maintaining your ZIP Code definitions (easy to go into your custom object to edit a single ZIP Code-territory mapping entry if you have a realignment of territories).
  • You don't have to contend with character limits in your assignment rules, since ZIP Codes are stored in the custom object, so you can store as many as you need.
  • Automatic data quality enforcement — the ZIP Code has to be a valid entry in your custom object.
  • Con: You have to use a custom ZIP Code field as opposed to the standard ZIP Code field that's part of the address field. This design can take on many permutations to fit various scenarios — it depends on the use case.

Approach 3: Custom Object with Apex Trigger

This solution builds on the table-driven approach above, but leverages Apex instead of the cross-object formula field and custom ZIP Code field. Here's the flow: the user fills out the standard ZIP Code field as usual, Apex triggers are invoked on new Account creation and update, perform a lookup against your ZIP Code mappings in your custom object, and update the custom fields that represent Account-territory relationships. Your territory assignment rules evaluate the custom field on the Account that's updated by Apex, and assign the Account accordingly.

This approach has all the advantages listed above, plus the ability to continue using the standard ZIP Code field. It's also easy to add custom validation via Apex so a user can only use a ZIP Code that you've defined in your custom object.

Consider voting on the idea exchange for this idea.

Número del artículo de conocimiento

000385599

 
Cargando
Salesforce Help | Article