Sub topic 7
The role hierarchy: access flows upward
This chapter assumes you know what org-wide defaults (OWD) are and how a user's profile and permission sets grant object permissions. It also assumes you have seen the Roles chapter, which explains that a role is a position in a tree and is not a profile. Here the focus is on how the tree turns into record access.
What the hierarchy does
The role hierarchy is a tree of roles. Each user can be assigned to at most one role. When an object's OWD is Private or Public Read Only, the hierarchy lets users higher in the tree reach records owned by users below them.
The rule is simple. A user gets the same level of access to a record as the record's owner has, plus access to records owned by any user in a role below theirs. Access flows upward only. A manager sees the work of their reports. A report does not see the manager's records.
The hierarchy never gives more than the object permissions allow. If the profile and permission sets do not grant Read on Opportunity, a Vice President in a high role still cannot read opportunities. Sharing can only open access to records for an object the user is already allowed to use.
In the diagram, a record owned by Sales Rep East is visible to VP Sales and the CEO. It is not visible to Sales Rep West or to VP Service, unless OWD or another sharing mechanism allows it.
Walking through an example
Suppose Account has an OWD of Private. Three users are involved.
- Priya is a Sales Rep East and owns an account called Acme.
- Marco is a Sales Rep West.
- Dana is the VP Sales, one level above both reps.
The result for Acme looks like this.
| User | Role position | Access to Acme | Why |
|---|---|---|---|
| Priya | Sales Rep East | Full (owner) | Owner of the record |
| Marco | Sales Rep West | None | Peer, not above Priya |
| Dana | VP Sales | Same as the owner | Above the owner in the hierarchy |
Marco cannot see Acme even though he works in the same department. Peers in different roles at the same level do not see each other's records under a Private OWD. If Marco and Priya are in the same role, they still do not see each other's records, because roles share a level and not a record. To open access sideways, you need a sharing rule, a team or a manual share, which a later chapter covers.
Roles are not reporting lines
The hierarchy is a model of record visibility. It is not an org chart. Several differences matter in practice.
- A user's manager field and a user's role are separate. The Manager field is used for approvals and some features. Changing it does not change record access.
- A role can contain many users, and a role can have no users at all. An empty role still holds its place in the tree and still passes access upward.
- The hierarchy should follow who needs to see whose data. Many orgs build a tree with a role for every job title, and this leads to deep trees that are hard to maintain and slow down sharing recalculation.
- A role is not a profile. A role says which records a user may reach. A profile says which objects and fields the user may use.
How the hierarchy applies to access levels
The hierarchy extends whichever access the owner has. If the owner can edit a record, a user above them in the tree gets edit access too. This is why the hierarchy matters most for Private and Public Read Only objects.
| OWD | Effect of the hierarchy |
|---|---|
| Private | Users above the owner get the owner's access. This is the main case where the hierarchy opens access. |
| Public Read Only | Everyone can read. Users above the owner also get edit access to the owner's records. |
| Public Read/Write | Everyone can already read and edit. The hierarchy adds nothing for viewing or editing. |
| Controlled by Parent | Access follows the parent record, so the hierarchy applies through the parent. |
The row for Public Read Only is the one people overlook. Without the hierarchy, a Public Read Only OWD would leave only the owner with edit rights. With it, managers can edit their reports' records.
Checking the effect with a query
You can confirm what the hierarchy produced by reading the share rows for a record. Records opened by the hierarchy do not usually appear as a separate row for each manager. The platform stores them in an implicit form, so you will see rows for the owner, teams and manual shares, but not one row for each ancestor role.
This query lists the share rows for one account and shows why each row exists, through the RowCause field.
SELECT Id, AccountId, UserOrGroupId, AccountAccessLevel, RowCause
FROM AccountShare
WHERE AccountId = '001XXXXXXXXXXXXXXX'Expect to see the owner with a RowCause of Owner. Do not expect Dana's hierarchy access to show up as a simple row for Dana. To see the final answer for a user, including hierarchy access, query UserRecordAccess instead.
SELECT RecordId, HasReadAccess, HasEditAccess, HasDeleteAccess
FROM UserRecordAccess
WHERE UserId = '005XXXXXXXXXXXXXXX'
AND RecordId = '001XXXXXXXXXXXXXXX'Run this once with Dana's user Id and once with Marco's. For Acme, Dana should return true for read and edit, and Marco should return false for all three, given the Private OWD.
Edge cases and common mistakes
- Moving a user changes access. When you move a user to a different role, the records they own move with them in the hierarchy. The new managers gain access and the old managers lose it. Salesforce recalculates sharing, and on large orgs this can take time.
- The owner's role decides, not the creator's. If you change a record's owner, the hierarchy access follows the new owner's role. Managers of the old owner lose access unless another mechanism keeps it.
- Users with no role. A user without a role sits outside the tree. Nobody gains access to their records through the hierarchy, and they do not gain access through it either. Give users who own shared data a role.
- Hierarchy access applies to owned records only. A manager reaches records their reports own. A manager does not automatically see records that were merely shared with a report through a rule or manual share. Whether they do depends on how the sharing rule was set up.
- Granting does not equal permission. If the manager's profile lacks the Delete permission on the object, being above the owner does not let them delete.
- Custom objects can opt out. The Grant Access Using Hierarchies setting for each custom object controls whether the hierarchy applies. The setting is covered in the next chapter. Standard objects always use the hierarchy.
A quick check you can run in Setup
To see the tree, open Setup, search for Roles, and choose Roles. Pick a role and review its users. To see access for one record, open the record, then use the Sharing button. For Account, Opportunity and Case, the Sharing Hierarchy button beside a record's owner also shows which users have access and why.
Exercise
Account OWD is Private. Lena owns an account and has the role Support Agent. Her manager Omar has the role Support Manager, directly above Support Agent. Tariq is a Support Agent too, in the same role as Lena. Who can see the account, and why?
Show answer
Lena can see it because she owns it. Omar can see it because his role is above the owner's role, and the hierarchy passes the owner's access upward, provided his profile or permission sets grant Read on Account. Tariq cannot see it. He is in the same role as Lena, not above it, and the hierarchy does not give access sideways. A sharing rule, team or manual share would be needed.
Exercise
Opportunity OWD is Public Read Only. Can a sales manager edit an opportunity owned by one of their reports, and what would change if OWD were Public Read/Write?
Show answer
Yes. The hierarchy gives the manager the owner's access, which includes edit, so the manager can edit the report's opportunities even though the OWD only lets other users read. Under Public Read/Write, every user with Edit permission on Opportunity could already edit it, so the hierarchy would add nothing for editing.