3

I need to control the visibility of multiple pageblocksections based on user's profile and status of the record.Currently I am using rendered attribute on pageblocksection and adding conditions like below.

AND($Profile.Name !='System Administrator',FC.Status__c!='Draft')

For each pageblocksection I need to add multiple conditions on rendered attribute.Is there any better way to control the visibility of pageblocksection based on profile and status of the record

4

I would move your logic into the controller. You have much more control this way. You can use this one property to set the visibility of many components on your page and keeps the logic in the controller layer as opposed to the view layer, which is always a best practice.

Something like this

public boolean getIsVisible(){
    string pId = UserInfo.getProfileId;
    string myStatus = yourRecord.Status__c;

    boolean isVis;
    //Add your logic statements here based on the above info, and set your boolean

    return isVis;
}

In your VF

...rendered="{!IsVisible}"....

To learn more about the Salesforce MVC model, take a look here

http://wiki.developerforce.com/page/Visualforce:_An_Overview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.