---
schema_version: "1"
id: c31cecbfc8cdcdcd5b975174dabbb85acf7861d4bfe6b714359ca9352e48037f
title: Checking for Object Accessibility
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/controller-std/pages-controller-std-checking-accessibility.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-controller-std-checking-accessibility.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2ee30f687a97ebc87ed42389da72f0816702adc2bbef1c6260d65ad0a1dabea6
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# 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:

```visualforce
{!$ObjectType.objectname.accessible}
```

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:

```visualforce
{!$ObjectType.Lead.accessible}
```

For custom objects, the code is similar:

```visualforce
{!$ObjectType.MyCustomObject__c.accessible}
```

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:

<!-- otherprops: apex_page -->

```markup
<apex:page standardController="Lead">
	<apex:pageBlock rendered="{!$ObjectType.Lead.accessible}">
		<p>This text will display if you can see the Lead object.</p>
	</apex:pageBlock>
</apex:page>
```

Provide an alternative message if a user can't access an object. For example:

<!-- otherprops: apex_page -->

```markup
<apex:page standardController="Lead">
	<apex:pageBlock rendered="{!$ObjectType.Lead.accessible}">
		<p>This text will display if you can see the Lead object.</p>
	</apex:pageBlock>
	<apex:pageBlock rendered="{! NOT($ObjectType.Lead.accessible) }">
		<p>Sorry, but you cannot see the data because you do not have access to the Lead object.</p>
	</apex:pageBlock>
</apex:page>
```
