Sub topic 4
Opening Access Upward with the Role Hierarchy
This chapter assumes you know what org-wide defaults (OWD) are and that every record has an owner. You should also know how profiles and permission sets grant object permissions. The role hierarchy adds one more piece to that model: it lets managers see the records their subordinates can see.
What the role hierarchy does
The role hierarchy is a tree of roles. A user can be assigned to one role. Users higher in the tree get access to records owned by, or shared with, users below them. Access never flows downward or sideways because of the hierarchy.
The hierarchy cannot grant more than the object permissions allow. A manager still needs the Read permission on the object through a profile or permission set. The hierarchy only opens record-level access.
In this tree, the VP of Sales can see records owned by either sales rep. The CEO can see everything below. Sales Rep East cannot see records owned by Sales Rep West, because they are peers. The VP of Finance cannot see the sales reps' records, because they sit on a different branch.
When the hierarchy applies
The hierarchy matters only when the OWD for an object is more restrictive than Public Read/Write. If the OWD is Private or Public Read Only, a manager needs the hierarchy to reach a subordinate's records for editing, or in the Private case, for viewing.
The effective access a manager gets is what the subordinate has. If a subordinate owns a record, the manager gets the owner's level: full access, including edit and delete. If the subordinate has only Read access through a sharing rule, the manager gets Read.
| OWD | Effect of the hierarchy |
|---|---|
| Private | Managers see and edit subordinates' records |
| Public Read Only | Managers can edit subordinates' records. Everyone else can only read. |
| Public Read/Write | No visible effect. Everyone can already edit. |
| Controlled by Parent | Access follows the parent record |
Grant Access Using Hierarchies
Each standard object has an OWD setting and a related option, Grant Access Using Hierarchies. It is on by default.
For custom objects, you can clear the checkbox. Then managers get no automatic access to subordinates' records for that object. Use this when records are sensitive, for example HR cases or salary data, and managers should not see them just because of their position.
You cannot clear the checkbox on standard objects. The hierarchy always applies to them.
Setting up roles
You create roles in Setup under Roles. Each role has a name and a parent role ("This role reports to"). A few points shape how you plan the tree.
- A role is not a profile. A profile controls what a user can do. A role controls which records the user can see by position.
- Each user has at most one role. A user with no role sees only records they own, records shared with them, and records the OWD makes public. Their own manager cannot see their records through the hierarchy either, because there is no role to place them in.
- Roles do not need to mirror the org chart. Build them around data visibility needs. A tree with a large number of levels slows sharing calculations and is harder to maintain.
- Salesforce documentation suggests keeping the hierarchy to a manageable depth, and many practitioners aim for no more than around ten levels.
Role-related sharing targets
Roles can also be used as targets in sharing rules, which later chapters cover. When you share to a role, Salesforce offers two variants:
- Roles: only users in that role.
- Roles and Subordinates: users in that role and every role below it.
The hierarchy itself grants access upward. A "Roles and Subordinates" target is a separate downward expansion for a rule. Do not confuse the two.
Checking who gets access through the hierarchy
Access through the hierarchy is implicit. For a standard object such as Account, it is not stored as a row in the share table. You will not see it with a query on AccountShare. The share table records explicit grants. To inspect these rows for a custom object, you can run this query:
SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause
FROM Invoice__Share
WHERE ParentId = '<invoice record Id>'The owner row has the row cause Owner. If the hierarchy gave a manager access, you will not see a separate row for the manager. To find that case, check the owner's role, then walk up the tree. The Sharing button on the record detail page lists who has access and shows the reason, including the hierarchy.
Common errors
- A manager cannot see a subordinate's record. Check three things. First, does the manager have the object's Read permission? Second, is the manager's role above the owner's role, on the same branch? Third, for a custom object, is Grant Access Using Hierarchies selected?
- A user without a role. The user does not appear in the tree, so no one gains access through that user. Assign a role.
- Assuming peers can see each other. Two reps with the same manager do not see each other's records under a Private OWD. Use a sharing rule or a public group.
- Moving a user between roles. Changing a user's role changes who can see their records. Salesforce recalculates sharing, and this can take time in a large org. Do it outside peak hours when you can.
- Using the hierarchy to fix a single exception. If one person outside the chain needs access, use manual sharing or a rule. Rebuilding the tree to suit one case affects everyone.
Design guidance
Keep the tree simple. Create roles only where visibility differs. If two groups of users need identical access, they can share one role even when the org chart separates them. Put the hierarchy to work for the common case: managers see their teams' data. Handle exceptions with the tools in the next chapters, rather than bending the tree.
Exercise
A custom object Invoice_c has an OWD of Private, and Grant Access Using Hierarchies is cleared. Maria owns an invoice. Her manager, Tom, is directly above her in the role hierarchy and has Read permission on Invoice_c. Can Tom see the invoice? Name one way to give him access without changing the checkbox.
Show answer
No. Clearing the checkbox removes the automatic upward access, so Tom's position gives him nothing. You can give him access with a manual share on the record, or with a sharing rule that targets Tom, his role, or a public group he belongs to.
Exercise
A user has no role assigned. Whose records can that user see under a Private OWD, and can that user's manager see the user's records through the hierarchy?
Show answer
The user sees records they own and records shared with them, directly or through rules and teams. The manager cannot see the user's records through the hierarchy, because a user with no role is not placed in the tree.