function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Best practices question - Controlling visibility based on profile when page is overridden

Currently, I have the default Case pages overridden. I have users that fall into a few different categories that all need to be able to create or manage cases.


1. Internal users in role abc.

2. Internal users in role xyz.

3. 3rd party contractors. 

4. Customer Portal users. 


And the list keeps growing, and growing.


Currently, the way I deal with this is to use one page as the overriding page, and within the page have code like this:


<apex:include pageName="pageNameabc" rendered="{!$user.ProfileId == 'abc123'}">


<apex:include pageName="pageNamexyz" rendered="{!$user.ProfileId == 'xyz123'}">

 I am not a fan of this implementation. Hard coding Id's is not ideal, but I've not found a better way to achieve what I need.

Message Edited by ehartye on 11-24-2009 08:49 AM
Have you considered using a single page with apex:inputField and apex:outputField for your case attributes? Visualforce respects field level security (FLS) for your profiles and automatically enforces it while rendering the page.


Why not have some booleans in your controller to set visibility, so you could then refer to them in your page.  At least you would not be hardcoding IDs.




<apex:include pageName="pageNameabc" rendered="{!isCustomPortalProfile}"> <apex:include pageName="pageNamexyz" rendered="{!NOT(isCustomPortalProfile)}">




public String userProfile{get;set;} public Profile profile; this.profile = [Select p.Name From Profile p where p.Id = :UserInfo.getProfileId()]; if(profile != null) userProfile = profile.Name; if(userProfile == 'Customer Portal Manager') { isCustomPortalProfile = true; } else{ isCustomPortalProfile = false; }



I have overridden the opportunity view page with a tabbed view, and I am hardcoding tabs' visibility

based on user's profile.


I think we can create a custom picklist field in user record, like casepagelayout (pagenameabc, pagenamexyz), and then in the VF page:


<apex:include pageName="pageNameabc" rendered="{!$user.casepagelayout == 'pagenameabc'}"> <apex:include pageName="pageNamexyz" rendered="{!$user.casepagelayout == 'pagenamexyz'}">





Have you considered 


The global variable $ObjectType gives you access to all standard and custom objects in your system. From these you can drill down further to the field level (e.g. $ObjectType.Case.CaseNumber) and get information about the field.
Visualforce page objects have an attribute "rendered" which controls the display of the object.