Rendering based on Object access in Salesforce

$ObjectType.ObjectName.accessible - Check whether the user has access to the object.

$ObjectType.ObjectName.createable - Check whether the user has create access to the object.

$ObjectType.ObjectName.updateable - Check whether the user has update or edit access to the object.

$ObjectType.ObjectName.deletable - Check whether the user has delete access to the object.

Sample Code:

<apex:page >
<apex:form >
    <apex:pageBlock rendered="{!$ObjectType.Employee__c.accessible}">
        <!-- Code to show components that should be visible only to to users who has access to Employee object -->
    </apex:pageBlock>
    <apex:pageBlock rendered="{!$ObjectType.Employee__c.createable}">
        <!-- Code to show components that should be visible only to to users who has create access to Employee object -->
    </apex:pageBlock>
    <apex:pageBlock rendered="{!$ObjectType.Employee__c.updateable}">
        <!-- Code to show components that should be visible only to to users who has update access to Employee object -->
    </apex:pageBlock>
    <apex:pageBlock rendered="{!$ObjectType.Employee__c.deletable}">
        <!-- Code to show components that should be visible only to to users who has delete access to Employee object -->
    </apex:pageBlock>
</apex:form>
</apex:page>

Cheers!!!

4 comments:

  1. How to Access the object in Salesforce in Coding and Simple method .......
    Salesforce Training Institute in Chennai

    ReplyDelete
  2. Hi, I have read your blog and I got a useful information from this blog. Thanks for sharing, keep posting..Salesforce is a cloud based CRM software. Today's most of the IT industry use this software for customer relationship management.
    Regards
    Salesforce Training | Salesforce.com Training in Chennai

    ReplyDelete
  3. how to create the dashboard in salesforce.com crm with optimized object salesforce training in chennai

    ReplyDelete
  4. Use Case Creating visualforce page to conditionally render elements from various custom objects based on the user's permission set assignment. Currently, the visualforce page in use uses the rendered condition based on the user profile. The issue is that all users have the same base profile and that we differentiation application access using permission sets.

    ReplyDelete