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
Michael Clarke 16Michael Clarke 16 

Create simple Visualforce page for Opportunity Lightning Record Page

I want to add a custom Highlights component to a Lightning Record Page. I have never created a Visualforce Page for adding to a Lightning canvas.
I may be way off the mark but gave it a go.
Any tips to get this working would be great!

<apex:page standardController="Opportunity">
    
    <apex:pageBlock title="Opportunity Summary">
        <apex:pageBlockTable value="{!Opportunity}" var="opp">
            <apex:column title="Customer(s)"/>
              <apex:column title="Guarantor(s)"/>
              <apex:column title="Lender"/>
              <apex:column title="Lender ID"/>
              <apex:column title="Broker"/>
              <apex:column title="Broker Code"/>
              <apex:column title="Loan Amount"/>
              <apex:column title="Close Date"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp1">
              <apex:column value="{!opp1.Applicant_1__c}"/>
              <apex:column title="Guarantor 1"/>
            <apex:column value="{!opp1.Lender__c}"/>
              <apex:column value="{!opp1.Account.Lender_ID__c}"/> <!-- Get customer field on Account object -->
              <apex:column value="{!opp1.User.FullName}"/> <!-- Get name of Opportunity Owner -->
              <apex:column value="{!opp1.User.AFG_Code__c}"/> <!-- Get custom field on User object -->
              <apex:column value="{!opp1.Amount}"/>
              <apex:column value="{!opp1.CloseDate}"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp2">
              <apex:column value="{!opp2.Applicant_2__c}"/>
              <apex:column title="Guarantor 2"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

Current Error Message: Invalid field USER for sObject Opportunity.
I am sure there are more errors.
Best Answer chosen by Michael Clarke 16
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Michael,
You are using incorrect fieldname.Use Owner.name instead of user.fullname.Try this one
<apex:page standardController="Opportunity">
    
    <apex:pageBlock title="Opportunity Summary">
        <apex:pageBlockTable value="{!Opportunity}" var="opp">
            <apex:column title="Customer(s)"/>
              <apex:column title="Guarantor(s)"/>
              <apex:column title="Lender"/>
              <apex:column title="Lender ID"/>
              <apex:column title="Broker"/>
              <apex:column title="Broker Code"/>
              <apex:column title="Loan Amount"/>
              <apex:column title="Close Date"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp1">
              <apex:column value="{!opp1.Applicant_1__c}"/>
              <apex:column title="Guarantor 1"/>
            <apex:column value="{!opp1.Lender__c}"/>
              <apex:column value="{!opp1.Account.Lender_ID__c}"/> <!-- Get customer field on Account object -->
              <apex:column value="{!opp1.owner.Name}"/> <!-- Get name of Opportunity Owner -->
              <apex:column value="{!opp1.User.AFG_Code__c}"/> <!-- Get custom field on User object -->
              <apex:column value="{!opp1.Amount}"/>
              <apex:column value="{!opp1.CloseDate}"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp2">
              <apex:column value="{!opp2.Applicant_2__c}"/>
              <apex:column title="Guarantor 2"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Michael,
You are using incorrect fieldname.Use Owner.name instead of user.fullname.Try this one
<apex:page standardController="Opportunity">
    
    <apex:pageBlock title="Opportunity Summary">
        <apex:pageBlockTable value="{!Opportunity}" var="opp">
            <apex:column title="Customer(s)"/>
              <apex:column title="Guarantor(s)"/>
              <apex:column title="Lender"/>
              <apex:column title="Lender ID"/>
              <apex:column title="Broker"/>
              <apex:column title="Broker Code"/>
              <apex:column title="Loan Amount"/>
              <apex:column title="Close Date"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp1">
              <apex:column value="{!opp1.Applicant_1__c}"/>
              <apex:column title="Guarantor 1"/>
            <apex:column value="{!opp1.Lender__c}"/>
              <apex:column value="{!opp1.Account.Lender_ID__c}"/> <!-- Get customer field on Account object -->
              <apex:column value="{!opp1.owner.Name}"/> <!-- Get name of Opportunity Owner -->
              <apex:column value="{!opp1.User.AFG_Code__c}"/> <!-- Get custom field on User object -->
              <apex:column value="{!opp1.Amount}"/>
              <apex:column value="{!opp1.CloseDate}"/>
           </apex:pageBlockTable>
        <apex:pageBlockTable value="{!Opportunity}" var="opp2">
              <apex:column value="{!opp2.Applicant_2__c}"/>
              <apex:column title="Guarantor 2"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
    
</apex:page>

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
This was selected as the best answer
Michael Clarke 16Michael Clarke 16
Thanks, plus I had to activate it for use on Lightning pages, learning new stuff today.