Newer Version Available
Territory2
File Suffix and Directory Location
Territory2 components have the suffix territory2 and are stored in the territories folder under the folder for the corresponding Territory2Model.
Version
Territory2 components are available in API version 32.0 and later.
Special Access Rules
The Territory2Model object has a State field in the SOAP API. States include Planning, Active, Archived, and a number of other states, such as Cloning, that indicate that a process is underway. Users who do not have the “Manage Territories” permission can access only territories 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 “Modify All Data” permission required by Metadata API. Using retrieve() without the “Manage Territories” permission will return only entities that belong to a Territory2Model in Active state. We recommend against retrieving without the “Manage Territories” permission because the call will retrieve only partial data.
Fields
| Field Name | Field Type | Description |
|---|---|---|
| accountAccessLevel | string | Specifies whether users in this territory can access accounts that are assigned
to this territory and are otherwise inaccessible. Valid values are:
|
| caseAccessLevel | string | Specifies whether users in this territory can access cases that are assigned to
this territory and are otherwise inaccessible. Valid values are:
|
| contactAccessLevel | string | Specifies whether users in this territory can access contacts that are assigned
to this territory and are otherwise inaccessible. Valid values are:
|
| customFields | FieldValue | Values for custom fields defined on the Territory2 object and used by this
territory. Their metadata is captured separately in CustomObject. Note the
following:
|
| description | string | A description of the territory. |
| name | string | Required. The user interface label for the territory. |
| opportunityAccessLevel | string | Specifies whether users in this territory can access opportunities that are
assigned to this territory and are otherwise inaccessible. Valid values are:
|
| parentTerritory | string | The name of the territory’s parent. When you specify the parent territory, use the developer name. Do not use the “fully qualified” name. Custom fields with no values are retrieved with values of type: <value xsi:nil="true"/>. You can also use <value xsi:nil="true"/> syntax to remove existing values in custom fields. |
| ruleAssociations | Territory2RuleAssociation | Represents an object assignment rule and its association to a territory. Use the developer name of the rule. |
| territory2Type | string | Required. The territory type that the territory belongs to. |
FieldValue
Represents the values of custom fields on the Territory2 object. Available in API version 32.0 and later.
| Field Name | Field Type | Description |
|---|---|---|
| name | string | Required. The user interface label for the territory. |
| value | any type | The value of the field, which can also be null. The field type is specified in the XML and depends on the field value. |
Territory2RuleAssociation
Represents the association of an object assignment rule to a territory. Available in API version 32.0 and later.
| Field Name | Field Type | Description |
|---|---|---|
| inherited | boolean | Required. Indicates whether the rule is inherited from a parent territory
(true) or local to the current territory
(false). Rule inheritance flows from the parent territory where the rule is created to the rule’s descendent territories (if any) in the territory model hierarchy. A local rule is created within a single territory and affects that territory only. |
| ruleName | string | Required. The name of a rule associated with the territory. ruleName doesn’t need to be fully qualified because Metadata API assumes that the rule belongs to the same model as the territory. |
Declarative Metadata Sample Definition
The following example shows the definition of a Territory2 component.
1<?xml version="1.0" encoding="UTF-8"?>
2<Territory2 xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3 <name>USA</name>
4 <description>United States sales</description>
5 <accountAccessLevel>Edit</accountAccessLevel>
6 <opportunityAccessLevel>Read</opportunityAccessLevel>
7 <caseAccessLevel>Edit</caseAccessLevel>
8 <contactAccessLevel>Edit</contactAccessLevel>
9 <parentTerritory>Worldwide_Sales</parentTerritory>
10 <territory2Type>Geo</territory2Type>
11 <ruleAssociations>
12 <ruleName>AccRule1</name>
13 <inherited>True</inherited>
14 </ruleAssociations>
15 <ruleAssociations>
16 <ruleName>AccRule2</name>
17 <inherited>False</inherited>
18 </ruleAssociations>
19 <customFields>
20 <name>Activation_DateTime__c</name>
21 <value xsi:type="xsd:dateTime">2014-07-16T05:05:00.000Z</value>
22 </customFields>
23 <customFields>
24 <name>AutoNumber__c</name>
25 <value xsi:type="xsd:string">T# 000001</value>
26 </customFields>
27 <customFields>
28 <name>DeactivationDate__c</name>
29 <value xsi:type="xsd:date">2016-07-12</value>
30 </customFields>
31 <customFields>
32 <name>External_Id__c</name>
33 <value xsi:type="xsd:string">AB2345</value>
34 </customFields>
35 <customFields>
36 <name>ManagersPhone__c</name>
37 <value xsi:nil="true"/>
38 </customFields>
39</Territory2>The following is a package.xml sample. FY13 and FY14 represent the 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 organization.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <members>FY13</members>
5 <members>FY14</members>
6 <name>Territory2Model</name>
7 </types>
8
9 <types>
10 <members>FY13.USA</members>
11 <members>FY13.Worldwide_Sales</members>
12 <members>FY14.APAC</members>
13 <members>FY14.USA</members>
14 <name>Territory2</name>
15 </types>
16
17 <version>36.0</version>
18</Package>Usage
- Triggers defined on Territory2 will not fire during a deploy() operation.
- Territory Management 2.0 components don’t support packaging or change sets and aren’t supported in CRUD calls.