Sub topic 7
Roles and record visibility
This chapter assumes you know what a user, a user licence and a profile are, and that you can open Setup as an administrator. It covers how roles work, how they differ from profiles and permission sets, and what to decide about a role when you create a user.
What a role does
A role controls which records a user can see because of where they sit in an organisation's reporting structure. A profile or permission set controls what a user can do with an object, such as read, create, edit or delete. A role controls which individual records of that object are visible.
Access to data therefore has two layers:
- Object and field access comes from the profile and permission sets. Without Read on Opportunity, a user sees no opportunities at all.
- Record access comes from the organisation-wide defaults, then roles, sharing rules, teams and manual shares. These can only open access up. They cannot grant a right that the profile denies.
A role never gives a user permission to do something. It only widens which records those permissions apply to.
The role hierarchy
Roles are arranged in a tree called the role hierarchy. A user in a role can see and, by default, edit the records owned by users in roles below them. They cannot see records owned by peers in other branches or by people above them, unless another mechanism shares those records.
In this example:
- The CEO can see records owned by everyone beneath them.
- The VP of Sales can see records owned by both sales managers, but not records owned by the support agent.
- Sales Manager East cannot see records owned by Sales Manager West, because they are peers.
Organisation-wide defaults set the baseline
The role hierarchy only matters when the organisation-wide default (OWD) for an object is more restrictive than the access people need. Each object has an OWD, such as Private, Public Read Only or Public Read/Write.
| OWD for the object | Effect of the role hierarchy |
|---|---|
| Private | Managers see their subordinates' records. Peers cannot see each other's records. |
| Public Read Only | Everyone can read all records. Only owners and users above them can edit. |
| Public Read/Write | Everyone can read and edit all records. The hierarchy adds nothing. |
| Controlled by Parent | Access follows the parent record, such as the account for a contact. |
When the OWD is Private, the hierarchy does the most work. When it is Public Read/Write, roles have no effect on that object's visibility.
Grant access using hierarchies
Each standard object has a setting called Grant Access Using Hierarchies. It is on by default. For custom objects, an administrator can turn it off. If it is off, managers do not automatically see the records of their reports, and the object is shared only through other mechanisms. Check this setting when a manager reports that they cannot see a subordinate's custom-object records.
Roles are optional, profiles are not
Every user must have a profile. A role is optional. A user with no role is not part of the hierarchy:
- Their records are not visible to anyone above them through the hierarchy, because they have no position in it.
- They do not see records owned by others through the hierarchy.
- They can still see records through the OWD, sharing rules and other mechanisms.
Leaving the role empty is a deliberate choice for some users, such as an integration user that should not appear under a manager. It is a mistake for ordinary staff who need to share data with their managers.
Roles are not licences or profiles
Learners often mix up the three. This table keeps them apart.
| Item | Question it answers | Required on a user? | Limited by licence capacity? |
|---|---|---|---|
| User licence | Which family of features and objects can this user be given? | Yes, through the profile | Yes |
| Profile | What baseline permissions does this user have? | Yes | No |
| Permission set | What extra permissions does this user have? | No | Only if it needs a permission set licence |
| Role | Which records does this user see through the hierarchy? | No | No |
Creating a role costs nothing. You can create as many as you need, and assigning a user to a role does not consume a licence. Licence capacity is only used by the user record itself, through its profile's licence.
Some users cannot be placed in the hierarchy in the usual way. Portal and Experience Cloud external users get roles of a different kind, generated per account, and have their own sharing rules. This chapter covers internal users only.
Designing a hierarchy
The role hierarchy should reflect who needs to see whose data. It does not have to copy the HR organisation chart. Some practical guidelines:
- Start from data visibility needs. Ask "who must see the records that this team owns?" and build upward from there.
- Keep it shallow. Salesforce supports a deep hierarchy, but each extra level adds sharing calculation work and makes troubleshooting harder. Aim for as few levels as meet the need.
- Use role names that describe the job, such as "Sales Manager West". Avoid personal names, because people move on.
- Avoid putting a user in a role only to give them access to one group of records. Use a sharing rule, a team or a public group for exceptions.
- Plan for change. Moving a role to a different parent recalculates access for every record involved, and in a large org this can take time.
Roles also drive other features
A role is more than a visibility setting. Depending on the org's configuration, the role can also be used in:
- Forecast rollups, where the hierarchy determines who sees whose forecast numbers.
- Reports that show "My team's" records.
- Sharing rules that share records with "Roles and Subordinates".
- Assignment of groups, queues and public group membership.
Check these before you restructure roles. A change made for visibility may alter a forecast.
Assigning a role to a user
You pick the role while creating or editing the user. The field is called Role on the user record, and it is optional on the form.
- In Setup, enter Users in Quick Find and choose Users.
- Click New User to create one, or click Edit next to an existing user.
- Choose a value in the Role lookup. Only roles that exist in the org appear.
- Fill in the other required fields and save.
A change of role takes effect through a sharing recalculation. The user may not see the new set of records the instant you save, especially in orgs with a large data volume.
Querying roles
You can inspect the hierarchy with SOQL. The UserRole object holds the roles, and each user record holds a UserRoleId.
SELECT Id, Name, ParentRoleId
FROM UserRole
ORDER BY NameTo see who is assigned to which role:
SELECT Name, Username, UserRole.Name, Profile.Name
FROM User
WHERE IsActive = true
ORDER BY UserRole.Name, NameUsers whose UserRole.Name is empty have no role. In a typical sales org, that list should contain only integration or automation users.
Common problems with roles
- A manager cannot see a report's records. Check that the OWD is not Public Read/Write (in which case there is nothing to explain), that Grant Access Using Hierarchies is on for a custom object, that the manager is above the owner in the hierarchy, and that the owner's role is set at all.
- A user sees too much. Look at the OWD first, then at sharing rules that target their role and at whether the profile has View All or Modify All permissions. These override both the OWD and the hierarchy.
- A user cannot be deactivated cleanly. Roles do not block deactivation, but records owned by the user stay in the hierarchy position of the old role. Transfer ownership first if that matters.
- The new user sees no data. The role is blank, or the profile lacks object permissions. Remember that role and profile solve different problems.
How this fits into creating a user
When you create a user, treat the role as the last of three decisions:
- Pick the licence, and the profile that matches it.
- Add permission sets for extra functions.
- Pick the role that places the user in the right place for record visibility.
Only the first decision affects licence capacity. The role can be changed later at no cost, though doing so triggers a sharing recalculation.
Exercise
A sales rep's manager can see none of the rep's opportunities. The rep has a role, and the manager has a role directly above the rep's role. The opportunity OWD is Private. List two things you would check, and explain why changing the manager's profile would not be the first step.
Show answer
Check that the rep's role is actually below the manager's in the hierarchy (and that the manager has a role at all), and check whether the opportunity records are owned by the rep, since the hierarchy shares records by owner. Also confirm the manager's profile has Read on Opportunity, because role access cannot grant object permission. A profile change would not be the first step because the profile controls what a user can do with an object, while the symptom is about which records are visible, which is a role and sharing question.
Exercise
Does assigning a user to a role consume a user licence? Why or why not?
Show answer
No. A licence is consumed by the user record, through the licence attached to its profile. A role is only a position in the hierarchy, and you can create and assign as many as you need without affecting licence capacity.