Territory2Settings

Represents an org’s Territory2 settings. Use Territory2 settings to set the access level that Sales Territories users have to records associated with sales territories, and to enable features. The standard record access settings apply to accounts and opportunities. With Private default internal access for contacts or cases, you can also set access for those records.

In the package manifest, all organization settings metadata types are accessed using the Settings name. See Settings for details.

Parent Type 

This type extends Metadata and inherits its fields.

File Suffix and Directory Location 

Territory2Settings values are stored in a single file named Territory2.settings in the settings directory of the corresponding package directory. The .settings files are different from other named components because there’s only one settings file for each settings component.

Version 

Introduced in API version 32.0.

Fields 

defaultAccountAccessLevel 

  • Type: string
  • Required: No
  • Description: Sets the default level of access that users have to account records in territories: view and edit accounts assigned to territories or view, edit, transfer, and delete accounts assigned to territories.

defaultCaseAccessLevel 

  • Type: string
  • Required: No
  • Description: Sets the default level of access that users have to case records in territories: view and edit accounts assigned to territories or view, edit, transfer, and delete accounts assigned to territories.

defaultContactAccessLevel 

  • Type: string
  • Required: No
  • Description: Sets the default level of access that users have to contact records in territories: view and edit accounts assigned to territories or view, edit, transfer, and delete accounts assigned to territories.

defaultOpportunityAccessLevel 

  • Type: string
  • Required: No
  • Description: Sets the default level of access that users have to opportunity records in territories: view and edit accounts assigned to territories or view, edit, transfer, and delete accounts assigned to territories.

enableTerritoryManagement2 

  • Type: boolean
  • Required: No
  • Introduced: API version 47.0
  • Description: Enables and disables Sales Territories only. If true, Sales Territories is enabled. If false (default), Enterprise Territory Management isn’t enabled. Enabling and disabling Sales Territories is exclusive of all other operations, and the field value must be true before other territory-management operations can run.

opportunityFilterSettings 

  • Type: Territory2SettingsOpportunityFilter
  • Required: No
  • Introduced: API version 34.0
  • Description: Optional. Specifies an Apex class to assign territories to opportunities and whether you want to run it when an opportunity is created.

showTM2EnabledBanner 

  • Type: boolean
  • Required: No
  • Introduced: API version 49.0
  • Description: If true, a success banner appears on the Territory Settings page in Setup.

supportedObjects 

  • Type: Territory2SupportedObject[]
  • Required: No
  • Introduced: API version 57.0
  • Description: Sets the user access levels of all objects that support territory assignments in the org.

t2ForecastAccessLevel 

  • Type: string (enumeration of type string)

  • Required: No

  • Description: Sets the access level that users in a parent territory get to the opportunities assigned to its child territories, regardless of who owns the opportunities.

    Available in API version 49.0 and later.

  • Possible values:

    • View
    • Edit

tm2BypassRealignAccInsert 

  • Type: boolean
  • Required: No
  • Introduced: API version 53.0
  • Description: If true, account assignment rules don’t run during account insert jobs.

tm2EnableUserAssignmentLog 

  • Type: boolean
  • Required: No
  • Introduced: API version 57.0
  • Description: If true, when a user is assigned to a territory, the assignment action is logged.

Territory2SettingsOpportunityFilter Type 

This subtype specifies an Apex class that assigns territories to opportunities. You can run the Apex class automatically every time a user creates an opportunity, or run it by using multithreading.

Fields 

apexClassName 

  • Type: string
  • Required: Yes
  • Description: Represents the Apex class name.

enableFilter 

  • Type: boolean
  • Required: Yes
  • Description: If true, the Apex class is used to assign territories to opportunities.

runMultiThreaded 

  • Type: boolean
  • Required: Yes
  • Introduced: API version 62.0
  • Description: Required. If true, the Apex class runs by using multithreading, which can improve performance. Set this value to true only if you’re assigning opportunity or opportunity product splits, and your Apex code can run with multithreading. This field has a default value of false.

runOnCreate 

  • Type: boolean
  • Required: Yes
  • Description: If true, the Apex class runs automatically every time a user creates an opportunity.

Territory2SupportedObject Type 

Sets the user access levels of all objects that support territory assignments in the org.

Fields 

defaultAccessLevel 

  • Type: string (enumeration of type string)
  • Required: Yes
  • Description: Required. The default user access level as permitted by the organization’s sharing settings.
  • Possible values:
    • Read
    • Edit
    • Transfer
    • All

objectType 

  • Type: string
  • Required: Yes
  • Description: Required. The only supported object type is Lead.

state 

  • Type: string (enumeration of type string)
  • Required: Yes
  • Description: Required.
  • Possible values:
    • Disabled
    • Enabled

Declarative Metadata Sample Definition 

The following example shows the definition of a Territory2Settings component.

1<?xml version="1.0" encoding="UTF-8"?>
2<Territory2Settings xmlns="http://soap.sforce.com/2006/04/metadata">
3    <defaultAccountAccessLevel>Owner</defaultAccountAccessLevel>
4    <defaultOpportunityAccessLevel>Read</defaultOpportunityAccessLevel>
5    <defaultCaseAccessLevel>None</defaultCaseAccessLevel>
6    <defaultContactAccessLevel>Edit</defaultContactAccessLevel>
7    <enableTerritoryManagement2>true</enableTerritoryManagement2>
8    <showTM2EnabledBanner>true</showTM2EnabledBanner>
9    <supportedObjects>
10       <defaultAccessLevel>Read</defaultAccessLevel>
11       <state>Disabled</state>
12       <objectType>Lead</objectType>
13    </supportedObjects>
14    <tm2EnableUserAssignmentLog>true</tm2EnableUserAssignmentLog>
15    <t2ForecastAccessLevel>View</t2ForecastAccessLevel>
16</Territory2Settings>

Usage 

Sales Territories components don’t support packaging or change sets and aren’t supported in CRUD calls.

Wildcard Support in the Manifest File 

The wildcard character * (asterisk) in the package.xml manifest file doesn’t apply to metadata types for feature settings. The wildcard applies only when retrieving all settings, not for an individual setting. For details, see Settings. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.