+ Start a Discussion
JoshGuiJoshGui 

Drop-down selection based on Visualforce Page Access

We'd like to have a dynamic drop-down (apex selectList)  with visualforce pages being the options to redirect a user to.  You can set what visualforce pages a user has access to on the profile.

 

Does anyone know of a way to be able to make this list dynamic based on what profile a user has?  I hope I'm being clear!

sfdcfoxsfdcfox

You'd have to use the metadata API to get to that information, which is trivially difficult at best. I wouldn't recommend trying to do it that way, it's far too much effort for the small gain.

JoshGuiJoshGui

Ah, gotcha.  Thanks!  I haven't had to use the metadata api yet.  I've seen some documentation about using apex Schema methods to access this information, as well?  Am I wrong?  To be honest, at this point I am not skilled enough to use either method.  Will just have to scratch it for now.

 

 

sfdcfoxsfdcfox

Schema does offer a lot of insight into the metadata that surrounds fields and objects, but doesn't handle things like profiles and pages (at least, not yet). There is a ApexPages object that includes a static Page object (so you can do things like return Page.myCustomPage to direct a user to a particular page), but this has no way to enumerate pages or determine their access rights per-user. I wish I had a better solution for you, but it appears that you're stuck with not knowing for right now.