Posts

Showing posts with the label territory

Salesforce Fact #841 | Apply to Child Territories in territory assignment rule

Image
There is an option 'Apply to Child Territories' while setting up a territory assignment rule. Let's see how it works. Suppose we have two territories 'Test Territory2' and 'Test Territory4', Test Territory4 is the child of Test Territory2. We have setup two rules for each of the territory as below: 1) for territory2, Account Industry equals 'Agriculture', Apply to Child Territories option checked. 2) for Territory4, Account Type equals 'Prospect', Apply to child territories option unchecked. Now, if an account only meets the first criteria, it is assigned to territory2. If an account only meets the second criteria, it is assigned to no territory. If an account meets both the criteria, it is assigned to territory4. So, if the Apply to Child Territories checkbox is checked, the rule condition of the child territory is checked in conjunction with the rule condition of the parent territory. Attached are the screenshots.

Salesforce Fact #765 | Assigning leads to territory using data load

Image
We can now assign Leads to territories. The same can be done using data load as well. For this, we need to import records in the ObjectTerritory2Association object and specify the Lead record Id in ObjectId field. Note: If you are using DataLoader and encounter an error 'Invalid Id', please update it to the latest version. Reference:  https://forceforfun.com/2022/10/25/update-dataloader-to-take-advantage-of-assigning-leads-to-territories/ Attached are the screenshots.

Salesforce Fact #760 | Territory Assignment rule on account save

Image
There is a checkbox 'Evaluate this account against territory rules on save' on the Account layout to run the territory assignment rules. In order to make the checkbox visible, go to Account Page Layout -> Layout Properties -> Select show on edit page. It can also be marked as checked by default if the option 'Default' is selected. Whenever an account is assigned to a territory using the territory assignment rule, an AccountShare row is created with RowCause='Territory'. Reference:  https://help.salesforce.com/s/articleView?id=000385116&type=1 Attached are the screenshots.

Salesforce Fact #759 | AccountUserTerritory2View

There is an Sobject called AccountUserTerritory2View which tracks the users present in the assigned territories for a particular account. It basically simulates the 'Users in Assigned Territories' related list. In order to perform SOQL on this Sobject, a filter is required on the AccountId field. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_accountuserterritory2view.htm

Salesforce Fact #703 | POC on adding a user to multiple territories using screen flow

Image
UserTerritory2Association object keeps track of the user assignment to the territories. Let's have an automation leveraging screen flow to let admins add a user to multiple territories in a single go. In this example, we have created a screen flow which takes the userid input and also allows the user to select multiple territories(in this case, it is max 5). Then, we are checking whether the user is already part of the territory, if not we are creating UserTerritory2Association records which eventually adds the user to the selected territories. Note: Since Territory2 object is not supported in UI API, we get an error on selecting the territory but it can be ignored. Attached are the screenshots.

Salesforce Fact #639 | Filter-based opp territory assignment

In order to use an apex class for filter-based opportunity territory assignment, the apex class needs to implement the  TerritoryMgmt.OpportunityTerritory2AssignmentFilter interface and it needs to implement the getOpportunityTerritory2Assignments() method. Reference:  https://help.salesforce.com/s/articleView?id=sf.tm2_enable_ota.htm&type=5