I worked for an organization that uses Salesforce CRM. While working on the project, there were roles (positions) for HR, manager, and employee. The access level of roles in such a way that no one can view or access each other’s data, like a manager can only view the data of the records accessed to him.
However, the requirement was that, people in a particular role should see the data from top to bottom, like HR-> Manager-> Employee. For that, we have a feature called Role Hierarchy in Salesforce.
Here, I will explain about the Role and Role Hierarchy in Salesforce. In that, we will see how to add roles to the role hierarchy and assign users to roles in Salesforce with the following examples:
- Example 1: Add Roles to Role Hierarchy in Salesforce.
- Example 2: Assign a User to a Role in Salesforce.
- Example 3: Assign Role to User from User Profile in Salesforce.
Roles in Salesforce
A role in Salesforce defines a user’s visibility access at the record level. Roles show the user’s position in the organization. Simply, it describes what a user could see within Salesforce.
For example, your organization has different roles, and some users work in those roles. Now, the admin has given permission to each role, and the users in that role can access the data according to the permission the admin has given to that role.
Role Hierarchy in Salesforce
In Salesforce, roles come under record-level security. We can control access data when we set up the role hierarchy, and role hierarchy determines the flow of record-level access. Each role has a specific level of authority and responsibility from a higher position to a lower positional structure.
The important thing is that in Salesforce, a role can only be used when the object’s OWD (Organization-Wide Default) is Private.
When the OWD(Organization-Wide Default) is not private, there is no need to use role hierarchy because users can access each other’s records. On the other hand, when the OWD is private, we can access records from the higher level to the lower level using role hierarchy.

Here, we can edit the Role Name as per our requirements.
Example 1: Add Roles to Role Hierarchy in Salesforce
Using the following steps, we can add roles to the role hierarchy or we also can edit existing roles in Salesforce.
1. Click on the “Gear icon,” then go to “Setup” and in “Quick Find Box” -> Search ” Roles” -> Click on “Roles.”

2. Click on the Set up Role option.

3. <