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
aamDevaamDev 

Not Render Link if No Page Access

I've got a VF page with some links to other VF pages. I'd like for a link to render only if that user's profile has been enabled to access the link's page. How do I do that?

 

Thanks in advance.

Melvin_DeveloperMelvin_Developer

Have you see the rendered attribute on visualforce tags? try using that!

Try something like:

 

 

//VF Page:
<apex:outputpanel id="theLink" rendered="{!accessEnabled}">
      <a href="what ever" ></a>
</apex:outputpanel>


//Controller:
public Boolean accessEnabled {get; set;}

 

set the value in the controller to true or false and the link will be rendered (or not rendered) appropriatly.

Hope this answers your question!

 

 

aamDevaamDev

Thanks for telling me about the rendered tag, I had never heard of it...

 

But seriously...

 

Did you know that you can grant access to Visualforce pages through the security link of that page within Setup, and that you can enable a page through a user's profile?

 

My org's user profiles may change, making it inefficient to check against a list of profiles within a controller. Therefore, the best solution would be to check against whether a page has been enabled for this profile.

 

What I want to know is whether there is some functionality on the global $Profile that works similarly to $ObjectType.Lead.accessible.

 

I apologize, I should have been a lot more specific in my question, and definitely will remember not to assume too much.

 

Thanks.