---
schema_version: "1"
id: 11215a7d7214998658949c865515a0c0df40cefc2ffc099e219239d55286b302
title: Territory2Settings
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_territory2settings.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_territory2settings.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 401dacdd0a830e5b558f57b0dc666cffc7228122e31d533848bfec40dc3dc6b5
description: 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.
---
# 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.

This type extends the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

In the package manifest, all organization settings metadata types are accessed using the Settings name. See [Settings](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_settings.htm "Represents the organization settings related to a feature. For example, your password policies, session settings and network access controls are all available in the SecuritySettings component type.") for details.

## 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

Territory2Settings is available in API version 32.0 and later.

## Fields

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d898934e111">Field Name</th>

              <th class="featureTableHeader  " id="d898934e114">Field Type</th>

              <th class="featureTableHeader  " id="d898934e117">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">defaultAccountAccessLevel</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">string</td>

              <td class="entry" headers="d898934e117" data-title="Description">Sets the default level of access that users have to account records in
                territories: <kbd class="ph userinput">view</kbd> and <kbd class="ph userinput">edit</kbd> accounts
                assigned to territories or <kbd class="ph userinput">view</kbd>, <kbd class="ph userinput">edit</kbd>,
                <kbd class="ph userinput">transfer</kbd>, and <kbd class="ph userinput">delete</kbd> accounts
                assigned to territories.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">defaultCaseAccessLevel</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">string</td>

              <td class="entry" headers="d898934e117" data-title="Description">Sets the default level of access that users have to case records in
                territories: <kbd class="ph userinput">view</kbd> and <kbd class="ph userinput">edit</kbd> accounts
                assigned to territories or <kbd class="ph userinput">view</kbd>, <kbd class="ph userinput">edit</kbd>,
                <kbd class="ph userinput">transfer</kbd>, and <kbd class="ph userinput">delete</kbd> accounts
                assigned to territories.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">defaultContactAccessLevel</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">string</td>

              <td class="entry" headers="d898934e117" data-title="Description">Sets the default level of access that users have to contact records in
                territories: <kbd class="ph userinput">view</kbd> and <kbd class="ph userinput">edit</kbd> accounts
                assigned to territories or <kbd class="ph userinput">view</kbd>, <kbd class="ph userinput">edit</kbd>,
                <kbd class="ph userinput">transfer</kbd>, and <kbd class="ph userinput">delete</kbd> accounts
                assigned to territories.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">defaultOpportunityAccessLevel</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">string</td>

              <td class="entry" headers="d898934e117" data-title="Description">Sets the default level of access that users have to opportunity records in
                territories: <kbd class="ph userinput">view</kbd> and <kbd class="ph userinput">edit</kbd> accounts
                assigned to territories or <kbd class="ph userinput">view</kbd>, <kbd class="ph userinput">edit</kbd>,
                <kbd class="ph userinput">transfer</kbd>, and <kbd class="ph userinput">delete</kbd> accounts
                assigned to territories.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">enableTerritoryManagement2</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">boolean</td>

              <td class="entry" headers="d898934e117" data-title="Description">Enables and disables Sales Territories only. If <samp class="codeph nolang">true</samp>, Sales Territories is enabled. If
                <samp class="codeph nolang">false</samp> (default), Enterprise Territory
                Management isn’t enabled. Enabling and disabling Sales Territories is
                exclusive of all other operations, and the field value must be <samp class="codeph nolang">true</samp> before other territory-management operations can
                run. <p class="p">Available in API version 47.0 and later.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">opportunityFilterSettings</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type"><a class="xref" href="#Territory2SettingsOpportunityFilter">Territory2SettingsOpportunityFilter</a></td>

              <td class="entry" headers="d898934e117" data-title="Description">
                <p class="p">Optional. Specifies an Apex class to assign territories to opportunities and
                  whether you want to run it when an opportunity is created. Available in API
                  version 34.0 and later.</p>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">showTM2EnabledBanner</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">boolean</td>

              <td class="entry" headers="d898934e117" data-title="Description">If <samp class="codeph nolang">true</samp>, a success banner appears on the
                Territory Settings page in
                Setup.<p class="p">Available
                  in API version 49.0 and later.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">supportedObjects</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type"><a class="xref" href="#Territory2SupportedObject">Territory2SupportedObject[]</a></td>

              <td class="entry" headers="d898934e117" data-title="Description">
                <p class="p">Sets the user access levels of all objects that support territory assignments in
                  the org. Available in API version 57.0 and later.</p>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">t2ForecastAccessLevel</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">string</td>

              <td class="entry" headers="d898934e117" data-title="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.<div class="p">Valid
                  values are:<ul class="ul bulletList">
                    <li class="li"><samp class="codeph nolang">View</samp></li>

                    <li class="li"><samp class="codeph nolang">Edit</samp></li>

                  </ul>
                </div>
                <p class="p">Available in API version 49.0 and later.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">tm2BypassRealignAccInsert</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">boolean</td>

              <td class="entry" headers="d898934e117" data-title="Description">If <samp class="codeph nolang">true</samp>, account assignment rules don’t
                run during account insert jobs.<p class="p">Available in API version 53.0 and
                  later.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d898934e111" data-title="Field Name"><span class="keyword parmname">tm2EnableUserAssignmentLog</span></td>

              <td class="entry" headers="d898934e114" data-title="Field Type">boolean</td>

              <td class="entry" headers="d898934e117" data-title="Description">If <samp class="codeph nolang">true</samp>, when a user is assigned to a
                territory, the assignment action is logged.<p class="p">Available in API version 57.0 and
                  later.</p>
              </td>

            </tr>

          </tbody>

        </table>

## Territory2SettingsOpportunityFilter

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.

| Field Name | Description |
| --- | --- |
| apexClassName | 
Field Type

string

Description

Represents the Apex class name.





 |
| enableFilter | 

Field Type

boolean

Description

If true, the Apex class is used to assign territories to opportunities.





 |
| runMultiThreaded | 

Field Type

boolean

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.

Available in API version 62.0 and later.





 |
| runOnCreate | 

Field Type

boolean

Description

If true, the Apex class runs automatically every time a user creates an opportunity.





 |

## Territory2SupportedObject

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

| Field Name | Description |
| --- | --- |
| defaultAccessLevel | 
Field Type

string

Description

Required. The default user access level as permitted by the organization’s sharing settings. Valid values are:

- Read
- Edit
- Transfer
- All





 |
| objectType | 

Field Type

string

Description

Required. The only supported object type is Lead.



 |
| state | 

Field Type

string

Description

Required. Valid values are:

- Disabled
- Enabled







 |

## Declarative Metadata Sample Definition

The following example shows the definition of a Territory2Settings component.

<?xml version="1.0" encoding="UTF-8"?>
<Territory2Settings xmlns="http://soap.sforce.com/2006/04/metadata">
    <defaultAccountAccessLevel\>Owner</defaultAccountAccessLevel\>
    <defaultOpportunityAccessLevel\>Read</defaultOpportunityAccessLevel\>
    <defaultCaseAccessLevel\>None</defaultCaseAccessLevel\>
    <defaultContactAccessLevel\>Edit</defaultContactAccessLevel\>
    <enableTerritoryManagement2\>true</enableTerritoryManagement2\>
    <showTM2EnabledBanner\>true</showTM2EnabledBanner\>
    <supportedObjects\>
       <defaultAccessLevel\>Read</defaultAccessLevel\>
       <state\>Disabled</state\>
       <objectType\>Lead</objectType\>
    </supportedObjects\>
    <tm2EnableUserAssignmentLog\>true</tm2EnableUserAssignmentLog\>
    <t2ForecastAccessLevel\>View</t2ForecastAccessLevel\>
</Territory2Settings\>

## Usage

Sales Territories components don’t support packaging or change sets and aren’t supported in [CRUD calls](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_crud_based_calls_intro.htm "Use CRUD-based calls to work with metadata components in a manner similar to how synchronous API calls in the enterprise WSDL act upon objects.").

## 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](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_settings.htm). For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).