Monday, March 7, 2016

Salesforce: Role Hierarchy versus Manager

In Salesforce, we can define Role Hierarchy and Manager for a user. In many cases, Manager is the same user with the user defined one role above on the Role Hierarchy. But, it does not always have to follow Role Hierarchy.

Manager can be someone from other role hierarchy. The most important, out of the box - there is NO direct relationship between Manager with Role Hierarchy, so do not expect when you change role hierarchy of a user, the Manager will be auto changed.

Role Hierarchy
Salesforce offers user role hierarchy that can be use for sharing settings. This is to determine the levels of access that users have in Salesforce. This define user permission to access a record, usually user in higher role hierarchy have the ability to read, update and change record owner of records owned by users below the role hierarchy.

Role hierarchy also determine report generated when user run report configured for My team. Dynamic Dashboard would be the other usage of role hierarchy, user only able to user in below role hierarchy as running user.

This field is especially useful for approval processes workflow.

There are 2 validation rules defined by Salesforce when you set a user Manager:

1. Cannot report to itself (the same user)
Error message: A user can't be his or her own manager

2. Cannot be a user that report directly to that user
example: A report to B, so B cannot report to A.
OR user report to other user in child record,
example: A report to B, B report to C, so C cannot report to A.
Error message: You cannot set a hierarchy field to point to itself or a child record

Side Note: the same logic applied when you set parent and child Accounts.