Territory2Rule
Represents the metadata associated with a territory assignment rule associated with an object, such as Account. Available if Sales Territories has been enabled.
This type extends Metadata and inherits its fields.
Territory2Rule components have the suffix territory2Rule and are stored in the rules folder under the folder for the corresponding Territory2Model.
Introduced in API version 32.0.
The Territory2Model object has a State field in SOAP API. States include Planning, Active, Archived, and several other states, such as Cloning, that indicate that a process is underway. Users who don’t have the Manage Territories permission can access rules that belong to the model in Active state. The Manage Territories permission is required for deploy() calls for all territory management entities, in addition to the permissions required by Metadata API. Using retrieve() without the Manage Territories permission returns only entities that belong to a Territory2Model in Active state. We recommend against retrieving without the Manage Territories permission because the call retrieves only partial data.
The SOAP API and the user interface require that a user attempting to create or edit a rule has field-level security access to the fields referenced in the rule item. This restriction is relaxed for Metadata API deploy() operations, as they require both Manage Territories and either the Modify Metadata Through Metadata API Functions or Modify All Data permissions.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether the rule is active (
true) or inactive (false). Via the API, active rules run automatically when object records are created and edited. The exception is when the value of theIsExcludedFromRealignfield on an object record istrue, which prevents record assignment rules from evaluating that record.
- Type: string
- Required: No
- Description: An advanced filter condition. For example:
(1 AND 2) OR 3. Numbering must start at 1 and must be contiguous.
- Type: string
- Required: Yes
- Description: Required. The user interface label for the rule.
- Type: string
- Required: Yes
- Description: Required. The object that the rule is defined for. For API version 32.0, the only available object is Account.
- Type: Territory2RuleItem[]
- Required: No
- Description: The items that define a rule’s the selection criteria, such as
Billing StateequalsCalifornia.
Represents the association of a rule item to a rule.
Introduced in API version 32.0.
- Type: string
- Required: Yes
- Description: The standard or custom object field that the rule item operates on.
- Type: FilterOperation (enumeration of type string)
- Required: Yes
- Description: The criterion to apply for the rule item. For example:
equalsorstarts with. - Possible values:
- equals
- notEqual
- lessThan
- greaterThan
- lessOrEqual
- greaterOrEqual
- contains
- notContain
- startsWith
- includes
- excludes
- within — (
DISTANCEcriteria only)
- Type: string
- Required: No
- Description: The field value or values to evaluate. For example: if the field is
Billing ZIP/Postal Code, a value could be94105.
The following example shows the definition of a Territory2RuleItem component.
The following is a package.xml sample. FY13 and FY14 represent names of territory models and demonstrate that rules can have identical developer names within different models. A wildcard character (*) in place of the model name can be used to retrieve all rules in all models in an org.
- A territory rule can have up to 10 rule items.
- The sort order of rule items is implicitly derived from the position of the rule items in the XML
- Rules can’t be run via Metadata API.
- Territory Management 2.0 components don’t support packaging or change sets and aren’t supported in CRUD calls.
This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.