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

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)?


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:

And compare the counters.