function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Allen ManamelAllen Manamel 

How to traverse territories in Salesforce using SOQL

I have a field on contact object called 'Region' (Text formual field) whose end value would be in the range of 1-5. On the other hand, I have a territory model setup in my Salesforce instance. There are 5 territories with the Type Region that come on level 3 in model hierarchy. Here is my territory hierarchy
User-added image

Here are the five region type territories

User-added image

What I want is that if the value in Region field is 1 on contact page, it should go to the Region 1 territory and check the assigned users in the region 1. Similarly for other regions. I am taking an example where Region value on contact object is 3. In that case, I want the code to go to Region 3, Traverse the assigned users in region 3 and check the "Role in Territory field" in assigned user. And then there is some other processing. Right now I don't even know how to reach to that point.
Screenshot attached for Region 3.
User-added image
NagendraNagendra (Salesforce Developers) 
Hi Anji,

It sounds like you are looking to do criteria-based territory assignment - but based on your Region 3 screenshot - you don't have any assignment rules configured. Have you tried to configure any assignment rules yet?

Regards,
Nagendra