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 6 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Jean

    Member
    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

    Member
    August 5, 2018 at 7:21 pm

    Hello Jean, Thank you so much for the help.

  • Shashank

    Member
    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

Salesforce Integration Tutorial | Integrate Salesforce with Apps

Video in

This "𝐒𝐚𝐥𝐞𝐬𝐟𝐨𝐫𝐜𝐞 𝐈𝐧𝐭𝐞𝐠𝐫𝐚𝐭𝐢𝐨𝐧 𝐓𝐮𝐭𝐨𝐫𝐢𝐚𝐥" video by Edureka will help you understand what is Salesforce integration in detail. It will also address the various Salesforce integration…