Activity Forums Salesforce® Discussions How to limit section visibility based on profile in visualforce page?

  • How to limit section visibility based on profile in visualforce page?

    Posted by Shashank on August 5, 2018 at 5:19 pm

    Hello, I've developed a visualforce page which will be accessed by users of different profiles who can input and edit data as per their responsibilties. If there are five sections with different fields in each of them, I want certain profiles to have access only to certain sections of the visualforce page. Say, there are three profiles A,B and C. I want A and B to have access only to first three sections of the page. User with profile C shall have access to the entire page. Is there any way that I can hide the section of a vf page based on the user profile?

    Shashank replied 4 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • Jean

    August 5, 2018 at 6:02 pm

    You can use the rendered attribute on the pageblock or pageblock section, and use the UserInfo methods on your apex class to get the logged in user's profile information. This will render the page conditionally depending on the profile.

    for example: <apex:pageBlock rendered="{!userProfile=='System Administrator'}">

  • Shashank

    August 5, 2018 at 7:21 pm

    Hello Jean, Thank you so much for the help.

  • Shashank

    August 7, 2018 at 2:26 pm

    Is there any way to restrict the access to only first two sections to whoever creates the case in the visual-force page? Like, I've a custom button to vf page called as Quality report,  in Case layout. I want only two sections visible to the user who creates the case by clicking on the custom button. According to recent update for my requirement, any of the three profiles can create a case.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos