You need to sign in to do that
Don't have an account?
David Jorjani
How to find the pages a user has access to in apex?
I want to know what pages the current user has access to using apex and run a code dynamically to show a list of those pages on a visualforce page. I have found setupentityaccess but it works with permission sets and not profiles. I only use profiles at this point. Please let me know if there is a way to do this.
First fetch all the VF pages through select query and make a set of Vf page id set. Select query will be :
[Select id from ApexPage]
After fetch all the Users having Profile which you are refering and make a userId set. Query like :
[Select id from User wnere Profile.Name='Profile Name']
After that do select query on "UserRecordAccess". Like :
[SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId in: userIdSet AND RecordId in: vfPageIdSet]
It will give you all the Vf pages that Have access to that profile.
Thanks