Salesforce Security Apex Sharing on Account Using Territories as Targets (in English)
Updated 2026-11-07
What's changed since the video
Each change is dated and checked against Salesforce's own documentation.
- Surviving an owner change has a direct answer now. This video looked for a way around video 4.16: code's shares on an account were deleted when the owner changed. Since October 2026, standard objects can have sharing reasons of their own, and shares written with one stay through an owner change (Protect Apex Shares: Custom Row Causes on Standard Objects, Salesforce Developers blog, checked 2026-11-07). Territory buckets are still worth using when people move in and out of the same groups of accounts, so the shares don't have to.
- Enterprise Territory Management is now Sales Territories. The same feature, under its current name in Salesforce Help (Sales Territories Concepts, Salesforce Help, checked 2026-11-07).
Still right
- A territory can be a bucket for sharing: a branch of special territories, outside the sales model, that code fills with accounts and users.
- Code puts an account in a territory with an object-territory association, and a user with a user-territory association, a few lines each.
- The users in the territory get access to its accounts, at the levels set on the territory, with the opportunities and cases that come with them.
- Because the account is in the territory, not shared with a person, the access stays when the account's owner changes: it works like a dynamic sharing rule.
- Territory allocations: "Allocations for each territory model include up to 1,000 territories. But if you require more, Salesforce Customer Support can increase your allocations depending on your Salesforce edition," and "Requests for more than 20,000 territories per model are subject to approval" (Allocations and Considerations for Territories, Salesforce Help, checked 2026-11-07).
All videos in this series: Tietoturva-arkkitehtuuri
Video ladataan YouTubesta vasta, kun napsautat sitä.