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
moin shaik 8moin shaik 8 

Hi i have two users a and b for both same controller and same VF page have some 1 to 10 section and i want render section 6 to the user A and not visible to user b.When user A logged in visble section 6 as "solution ".I want code for controller and vf cod

Hi i have two users a and b for both same controller and same VF page have some 1 to 10 section and i want render section 6 to the user A and not visible to user b.When user A logged in visble section 6 as "solution ".I want code for controller and vf cod
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Moin,
  • Record types allow you to offer different business processes, picklist values, fields and page layouts to different users based on their profiles.
Please refer the below links for reference. I hope it will be helpful.

Please mark it as best answer if the information is informative.

BestRegards
RahulKumar
LBKLBK
You need to use rendered in Visualforce page block section to hide or show the section.

Here is a sample piece of code.
 
<apex:page StandardController="Account" >
  <apex:PageBlock >
      <apex:pageBlockSection >
          <apex:pageBlockSectionItem >
                Section 1          
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      <apex:pageBlockSection>
          <apex:pageBlockSectionItem >
                Section 2        
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
      <apex:pageBlockSection rendered="{!$User.LastName == 'LASTNAME'}" >
          <apex:pageBlockSectionItem >
                Section 6          
          </apex:pageBlockSectionItem>
      </apex:pageBlockSection>
  </apex:PageBlock>
</apex:page>
I would suggest  you to use the Profile name rather than the user name to achieve this. Because if you have more users with same profiles, they will have same access level.

You can use the rendered variable like below.

To use profile,
<apex:pageBlockSection rendered="{!$Profile.Name == 'System Administrator'}" >
To use UserName,
 
<apex:relatedList list="Opportunities" rendered="{!$User.Username == 'user1@mydevorg.com'}"/>
Hope this helps.


 
moin shaik 8moin shaik 8
Thank you
 
LBKLBK
Please mark the question as solved, if the answer helped you. It could help others too.