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.
Here is a screenshot of the page
Here is an example of what I am trying to do via the rendered condition (which would change the grid based on user permission set assignment):
apex:panelGrid columns="2" style="width:100%;" rendered="{!$User.Id == ObjectType.PermissionSetAssignment.Fields.AssigneeId && $ObjectType.PermissionSetAssignment.Fields.PermissionSetId == $ObjectType.PermissionSet.Fields.Id && $ObjectType.PermissionSet.Fields.Name == 'SOX Control Owner Permission Set' }"
c:GenericDataListComponent filter_p="Process_Owner__c='{!$User.Id}'" title="My Processes" objectName_p="SOX_Process__c" fieldSet_p="Dashboard_Regular_Process_FieldSet" pageSize_p="3" sortDirection_p="desc" orderByFieldName_p="LastModifiedDate" urlForNewRecord="{!URLFOR($Action.SOX_Process__c.New,null)}" hideButtons="true" />
c:GenericDataListComponent filter_p="Sub_Process_Owner__c='{!$User.Id}'" title="My Sub Processes" objectName_p="SOX_Sub_Process__c" fieldSet_p="Dashboard_Regular_SubProcess_FieldSet" pageSize_p="3" sortDirection_p="desc" orderByFieldName_p="LastModifiedDate" urlForNewRecord="{!URLFOR($Action.SOX_Sub_Process__c.New,null)}" hideButtons="true" />
/apex:panelGrid>"
Issue
When i access the screen above, it is blank.
The conditions set forth in the Rendered statement do not carry through relationally across objects.
How should this be restructured?
Is there a better way to do this without having to build a control class?
Best Answer
We cannot use the global variable '$ObjectType' to get object's record data. It can be used to get objects and its fields metadata (schema details) only.
Please see http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global_objecttype.htm
We can use global variable '$Setup' to access hierarchical custom settings which can be evaluated in 'rendered' attribute.
Update the rendered attribute as
rendered="{!$Setup.Permissions__c.SOX_Control_Owner_Permission_Set__c}"
Please see http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global_setup.htm