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
KCLKCL 

Compare 2 objects fields,

I have a custom object  Area "fields "are: fields are
area rep, area manager

We are using territory management. I am using below 2 queries to get the ids of 
UserTerritory2Association, Territory2Id, and Role_Number__c user name.

For Ex:arearep= arep12, we need to update the area rep name in the new text field in custom object Area

I am using  trigger on the Area custom object we need to use the logic in same trigger.


select id,Name,(select UserId,Id,Territory2Id from UserTerritory2Associations) from user where  isactive=true

SELECT DeveloperName,Id,Name,Role_Number__c FROM Territory2

 
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Seems like,the territory management can be applied for the Accounts and the standard Objects which are having the Master-detailed relationship with the Accounts only.

So,I would suggest you to update the field value on the Account first and then try to update field from Account record indirectly as the custom Object doesn't support this.

Please refer the below documentation:

https://help.salesforce.com/articleView?id=territories_def.htm&type=5

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri