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
VeevaEmsVeevaEms 

Trigger on UserTerritory?

I'd like to write a trigger on UserTerritory so that when Territory assignments change I can update a custom field on the User object with the assigned territory.

 

Can't seem to write triggers on the UserTerritory object.

 

Workaround is batch apex to update all users on some regular schedule, but I'd really like a better solution.

 

Any suggestions?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

You can't trigger on that today, so you'd have to use your batch Apex Code suggestion, or you could use some Visualforce code to perform updates when using the UI, but that's unreliable (won't work on API updates, for example). Unfortunately, that's all we can offer right now.