function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Teach_me_howTeach_me_how 

Compare the role of two users. How can i know who among them has the higher role?

How can i do this in apex(Class/trigger)?

RoyGiladRoyGilad

Hi,
Depends on how you define higher...
If you count number of levels from your highest role - you could count the number of levels using \ based on  'Find My Salesforce Users by Role Hierarchy' by Jeff Douglas:
http://blog.jeffdouglas.com/2011/02/15/find-my-salesforce-users-by-role-hierarchy/

And compare the counters.