Row-Level Security Example based on Territory Hierarchy and Record Ownership

If your territory hierarchy is specified with Territory Hierarchy 2.0, you can create a dataset to implement row-level security based on the territory hierarchy and record ownership. This example shows how you do this with a dataset for opportunities.

Prerequisites

Territory Hierarchy in security predicate is a beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com and applicable terms in the Product Terms Directory. To use this feature, contact your Salesforce.com account rep or Customer Support via help.salesforce.com. Use of this beta service is at the Customer's sole discretion.

Source data

This example assumes you have this source data:

Users—here you have 5 users:

Example user data

Territory hierarchy—here the territories of California and Oregon are grouped under US West, which is included in the US territory:

Example user data

Territory hierarchy user associations–here users are associated with a territory. For example, John is associated with the territory of California.

Example user data

Opportunities–here opportunities are identified by the territory in which they originated. For example, opportunity 1 is from California:

Example user data

Dataset content

Create a recipe or dataflow where you use the Flatten node to flatten the territory hierarchy into Territory2Ids,

Example user data

Then join the flattened territory hierarchy to the opportunity data:

Example user data

Security predicate

Now add this Security Predicate to the Output node:

'Territory2.TerritoryIDs' in ["$UserTerritory2Ids"]: