+ Start a Discussion
SanchSanch 

Checking Role Hierarchy in Apex Class

Hi there,

 

I want to know if it's possible to check if the current user's Role is higher than another user's role through Apex. Is this possible? Thanks.

 

Sanch

nagasnagas

it can be done by some customization like creating a text field in the user "level". 

for example

 

role       level

VP         1

CEO     2

SE       3

 

 

so on a user record write a workflow  sot hat it populates the level field based on your criteria like if userrole is VP fieldupdate of level to 1.

 

then based in the levels of two users you can figure out whose role is higher.

 

Its just an idea you may face some problems but i think there should be no issues.

SivarajanSivarajan

 

Hi Sanch,

 

In my case, I would to like to check logged user role with a role of particular record owner. If logged user role is on top of the record owner user role then I would like to show a visualforce page. any idea ?

magdielmagdiel

Hi,

 

Just in case as a reference I'm trying to accomplish same requirement and this post seems to provide hints to the solution,

 

http://boards.developerforce.com/t5/Apex-Code-Development/Role-Hierarchy-check-in-Apex-class/td-p/343299