Role Hierarchy Explained
By the end of this lesson, you'll be able to:
- Explain how the role hierarchy grants implicit record access
- Identify when the role hierarchy does NOT grant access to a custom object
Prerequisites: Organization-Wide Defaults & Sharing Settings
How the hierarchy grants access
Roles are arranged in a tree, and access flows upward: a user automatically inherits access to every record owned by (or shared with) the users in roles below them. This is separate from, and stacks on top of, the Organization-Wide Default baseline.
Unlike sharing rules, nothing needs to be explicitly configured per object — the hierarchy applies automatically to every standard object, and to custom objects unless it's been switched off.
Opting out for custom objects
Custom objects have a Grant Access Using Hierarchies checkbox in their sharing settings. Unchecking it stops the role hierarchy from automatically granting access for that object — useful for sensitive custom objects (like a Payroll__c object) where even a manager shouldn't automatically see every record below them.
Standard objects don't offer this opt-out — hierarchy access always applies to them.
Finding the top of the role hierarchy
List<UserRole> topLevelRoles = [
SELECT Id, Name, ParentRoleId
FROM UserRole
WHERE ParentRoleId = null
];
Roles with a null ParentRoleId sit at the very top of the hierarchy — every other role eventually rolls up to one of these.
Exercise
Write a SOQL query that returns the Name of every UserRole that is a direct child of a role named 'VP Sales'.
Show hint
Query UserRole where ParentRole.Name = 'VP Sales'.
Role Hierarchy Explained — Quick Check
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
The role hierarchy automatically grants users read (and usually edit) access to every record owned by, or shared with, the users below them — a manager sees what their reports see, without any extra configuration.