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
k78k78 

Is there an Apex method that will do what the entitywhylist.jsp page does?

If I am in salesforce I can go to a record, click on its sharing button and from there I can click on Expand List.  Next, I can find a username and click on the Why? link beside their name.  This will take me to the entitywhylist.jsp page which seems to simply be able to accept 2 arguments (record Id and user Id) and return a full explanation of what relationships and reasons permit the user to access that record.

 

My question then: Is there an Apex method that can do this.  If I have the record Id and the user Id is there an inexpensive way of returning the information provided by the entitywhylist page?  All the other similar solutions to questions like this seem to involve iterating over a potentially large number of groups and roles.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
Unfortunately, there is no "clean" way to do this in Apex Code. In fact, your best bet would be to simulate a call to entitywhylist.jsp directly using a pagereference and then parsing the resulting html output.

All Answers

sfdcfoxsfdcfox
Unfortunately, there is no "clean" way to do this in Apex Code. In fact, your best bet would be to simulate a call to entitywhylist.jsp directly using a pagereference and then parsing the resulting html output.
This was selected as the best answer
k78k78

OK.  That was what I feared.  Better than iterating over all the groups but still not the clean way I was hoping for.

 

Thanks for the answer.