You need to sign in to do that
Don't have an account?
Sivarajan
Role Hierarchy check in Apex class
Hi Everyone,
I would 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 How to do that it very simply ?
Thanks in advance !
There's actually a pre-built group sObject used for sharing rules that you might be able to use for this. For every role there's a group object with "RoleAndSubordinates" as it's type and the relatedId field as your higher role. You can query the groupMembers of this record and see if your other role is included. If so, it's lower in the hierarchy, otherwise it's not.
All Answers
I don't believe there is currently any way to do that.
Interesting use case, though. And let us know if you find a way to find that information.
There's actually a pre-built group sObject used for sharing rules that you might be able to use for this. For every role there's a group object with "RoleAndSubordinates" as it's type and the relatedId field as your higher role. You can query the groupMembers of this record and see if your other role is included. If so, it's lower in the hierarchy, otherwise it's not.
Not sure about proposed solution, tested this one and worked, dropped here for future reference,