Question:
Why Does the Territory Model Cloning Process Fail in Veeva CRM (Salesforce)?
Answer:
The term Territory Model from the perspective of Salesforce is not to be confused with the Territory Model records in Veeva Align.
A Territory Model represents a complete territory management system in Salesforce. It is part of the Enterprise Territory Management (ETM) feature. ETM is also referred to as Territory Management 2.0 (TM 2.0).
As a Salesforce CRM System Administrator, navigate to Setup -> Customize to access the options related to Territories, Territory Models, User Territory Associations. Alternatively, typing territor into the Quick Menu without quotes displays all available options as well. In the event, the Settings option displays only, that indicates that Territory Management 2.0 is not enabled in the CRM instance.
When accessing an existing Territory Model in the Territory Models section, the Clone button provides the ability to clone the Territory Model. This means the entire Territory Hierarchy and its related child data can be cloned into a new Territory Model.
The following Entity Relationship Diagram (ERD) from Territory Management 2.0 Objects displays all objects which are relevant in the TM 2.0 Model:
After clicking on the Clone button, a new Territory Model row is created. The State column displays Cloning Failed after a certain period of time in case it fails. If Cloning is in progress, the State column displays Cloning. In the event, the Cloning finishes without any issues, the State column displays Planning, since only one Territory Model can be active at one time.
The Territory Model Cloning process may fail due to the following reasons:
- There is a custom field on the Territory2 object, whose Unique property is checked
- There is a custom Picklist type field on the Territory2 object, which has inactive Picklist values
- There is a custom field on the Territory2 object, whose values point to non-existing (Phantom) CRM records
- There are incorrect or syntactically invalid Salesforce Assignment Rule and Criteria associated to the Territory2 records. As the Clone a Territory Model Salesforce documentation states, this is especially applied to Picklist type field values referenced in Assignment Rule Criteria. If a Picklist value is deleted, inactivated, replaced in the Picklist type field - and this Picklist value remains referenced in the Assignment Rule Criteria - the Cloning process fails
- There is a Custom Apex Trigger on the Territory2 or UserTerritory2Association object causing the issue
- There is an Assignment Rule containing a Date type field and Date value in its criteria
The solution is as follows (to each point respectively above):
- Uncheck the Unique property of the custom field.
- Activate the inactive Picklist values of the custom Picklist type field, or delete them.
- Be sure to null out the values of the custom field, which are in this state.
- Revise the Salesforce Assignment Rule Criteria - ObjectTerritory2AssignmentRule and ObjectTerritory2AssignmentRuleItem records.
Make sure that any Picklist values referenced in the criteria of the Assignment Rules are valid, active. - Deactivate the Custom Triggers on the Territory2 or UserTerritory2Association objects.
- Remove the Date type field and its Date value from the criteria.
After the cloning process is complete, they may be added again.
It is recommended to clear the Veeva Cache after any of the changes above are made.
In the event the exact cause is not found, a ticket needs to be raised to Salesforce Support.
Related Documentation:
Salesforce Documentation:
- Unable to clone territory model when users define a custom unique field on territory
- Cannot clone a territory model if it has assignment rules which use dates in their filters (TM 2) - Invalid date error
- Territory Management 2.0 Objects
- Clone a Territory Model