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
AndrewFisher_TGPAndrewFisher_TGP 

Profile Tab - Display Custom fields in VF using Std controller

I have created a Profile tab in user profile, but want to display an image from a custom field in the user profile by user, so if that field is populated it displays for that user.
I can do this for all users (see code below) but want it individually by user to allow me to control who dsiplays which image: eg User 1 is ticked on the custom field and the image shows, user 2 is not ticked so that user does not display it.

<apex:page showHeader="false" sidebar="false" standardController="User"> <apex:pageBlock > <apex:pageBlockSection columns="3"> <apex:pageblocksectionItem ><b> Welcome to Salesforce </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Accounts and Contacts </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Navigating Salesforce </b></apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vwsL" width="100" height="100"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyql" width="100" height="100"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqq" width="100" height="100"/> </apex:pageblocksectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock > <apex:pageBlockSection columns="3"> <apex:pageblocksectionItem ><b> Converting Leads </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Reports and Dashboards </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Chatter </b></apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqv" width="100" height="100"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr0" width="100" height="100"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr5" width="100" height="100"/> </apex:pageblocksectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
 
Swaraj Behera 7Swaraj Behera 7
Hi I hope you can use Rendered attribute to slove it.Give the User id in the below code.Please try it once.
 
<apex:page showHeader="false" sidebar="false" standardController="User">
<script type="text/javascript">;
    function ShowSection() {
         document.getElementById("pageid:formid:pageblockId").style.display ='block';
    }
</script> 
  <apex:pageBlock id='pageid' > 
  <apex:pageBlockSection columns="3" id='formid'> 
        <apex:pageblocksectionItem >
            <b> Welcome to Salesforce </b>
        </apex:pageblocksectionItem> 

        <apex:pageblocksectionItem >
            <b> Accounts and Contacts </b>
        </apex:pageblocksectionItem>

        <apex:pageblocksectionItem >
            <b> Navigating Salesforce </b>
        </apex:pageblocksectionItem> 

        <apex:pageblocksectionItem id='pageblockId'> 
            <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vwsL" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" /> 
        </apex:pageblocksectionItem>

        <apex:pageblocksectionItem > 
            <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyql" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" />
        </apex:pageblocksectionItem> 

        <apex:pageblocksectionItem > 
            <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqq" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" />
       </apex:pageblocksectionItem> 

  </apex:pageBlockSection> 
</apex:pageBlock> 
<apex:pageBlock > 
   <apex:pageBlockSection columns="3">
        <apex:pageblocksectionItem >
          <b> Converting Leads </b>
        </apex:pageblocksectionItem>

        <apex:pageblocksectionItem >
          <b> Reports and Dashboards </b>
        </apex:pageblocksectionItem> 

        <apex:pageblocksectionItem >
          <b> Chatter </b>
        </apex:pageblocksectionItem>

        <apex:pageblocksectionItem > 
            <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqv" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" />
       </apex:pageblocksectionItem> 

       <apex:pageblocksectionItem >
          <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr0" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" />
       </apex:pageblocksectionItem>

        <apex:pageblocksectionItem > 
            <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr5" width="100" height="100" rendered="{!IF (CONTAINS($User.id, 'id') True, False)}" />
        </apex:pageblocksectionItem> 

    </apex:pageBlockSection> 
  </apex:pageBlock> 
</apex:page>

 
AndrewFisher_TGPAndrewFisher_TGP
Fantastic, thanks very much I will try this now and let you know
AndrewFisher_TGPAndrewFisher_TGP
Nearly there - can get this to work for the user but not for the user to view others:

I added custom fields onto users which are to be ticked if they complete each of the 6 modules. What I now need to do is pull the id into the code of the profile page. 

<apex:page showHeader="false" sidebar="false" standardController="User" > <apex:pageBlock > <apex:pageBlockSection columns="3"> <apex:pageblocksectionItem ><b> Welcome to Salesforce </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Accounts and Contacts </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Navigating Salesforce </b></apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vwsL" width="100" height="100" rendered="{!$User.Badge_1__c}"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyql" width="100" height="100" rendered="{!$User.Badge_2__c}"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqq" width="100" height="100" rendered="{!$User.Badge_3__c}"/> </apex:pageblocksectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock > <apex:pageBlockSection columns="3"> <apex:pageblocksectionItem ><b> Converting Leads </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Reports and Dashboards </b></apex:pageblocksectionItem> <apex:pageblocksectionItem ><b> Chatter </b></apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyqv" width="100" height="100" rendered="{!$User.Badge_4__c}"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr0" width="100" height="100" rendered="{!$User.Badge_5__c}"/> </apex:pageblocksectionItem> <apex:pageblocksectionItem > <apex:image url="/servlet/servlet.FileDownload?file=015w0000002vyr5" width="100" height="100" rendered="{!$User.Badge_6__c}"/> </apex:pageblocksectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:page>