You need to sign in to do that
Don't have an account?
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.
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.
Page:
<apex:include pageName="pageNameabc" rendered="{!isCustomPortalProfile}"> <apex:include pageName="pageNamexyz" rendered="{!NOT(isCustomPortalProfile)}">
Controller:
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