Newer Version Available

This content describes an older version of this product. View Latest

Checking for Object Accessibility

If a user has insufficient privileges to view an object, any Visualforce page that uses a controller to render that object is inaccessible. To avoid this error, ensure that your Visualforce components only render if a user has access to the object associated with the controller.
You can check for the accessibility of an object like this:
This expression returns a true or false value.
For example, to check if you have access to the standard Lead object, use the following code:
For custom objects, the code is similar:
where MyCustomObject__c is the name of your custom object.
To ensure that a portion of your page will display only if a user has access to an object, use the rendered attribute on a component. For example, to display a page block if a user has access to the Lead object, you would do the following:
Provide an alternative message if a user can't access an object. For example: