I have a couple of static pages( just text no custom object involoved ) need to show to users and links to the pages need to be hidden if the user doesn't have privilege to do so. Is there any way to check that or I have to do with profile name match?

1 Answer 1


You can't directly check the permissions for the page-- you'd have to either go the long way around with a Metadata API query, which should be painful at best, or you can attempt to open each page on behalf of the user (e.g. via PageReference) and see if you get an error page or not. In the end, it's probably best to check profile names explicitly, although that runs the problem of another administrator later changing the page permissions or adding permission sets. Personally, I would recommend that you simply display the links, and allow the user to see the error message for themselves. This way, if they were told they should have access, they will have an idea why they do not have access instead of just reporting "I can't find the link you were talking about."

  • I don't think it's good idea to have them display if they are not entitled to do so. That might confuse users. I might give a try with metadata api or just name match to make it quick fix. Nov 6, 2013 at 17:20
  • I'm usually inclined to agree-- why give them a choice if they can't actually do it... but in this case, the effort may far exceed the benefits. Checking by profile name is a poor means of accomplishing the task, because you can't predict when an administrator will make a breaking change (either adding a page they can't access, or removing a page they could access). Maybe you should look at Custom Settings, instead; at least then you'd have the flexibility of configuring per-profile settings without code changes.
    – sfdcfox
    Nov 6, 2013 at 17:25
  • For the custom settings, you meant I can set so that some of CS can be only seen by specific profile or I need to have a key/value pair for each pages to do show/hide. Nov 6, 2013 at 18:12
  • I would use CS type hierarchy, set org defaults to minimum default pages for all users then set override values per profile/per user as necessary to indicate page access. This should scale well for an average sized organization.
    – sfdcfox
    Nov 6, 2013 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .