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
Andrew EversleyAndrew Eversley 

Displaying Records, Fields, and Tables - Visualforce Page - Trailhead Error

Hello Community, 

Need some assistance with and error on a VisualSource Page Trailhead Challenge

Here is the Criteria:
Create a page which displays a subset of Opportunity fields using apex:outputField components. Bind the Name, Amount, Close Date and Account Name fields to the apex:outputField components.The page must be named 'OppView'.
It must reference the Opportunity standard controller.
It must have an apex:outputField component bound to the Opportunity Name.
It must have an apex:outputField component bound to the Opportunity Amount.
It must have an apex:outputField component bound to the Opportunity Close Date.
It must have an apex:outputField component bound to the Account Name of the Opportunity.

Here is the error I'm receiving
Challenge not yet complete... here's what's wrong: 
The page does not include a apex:outputField component bound to the opportunity name

Here is my code for the page:
<apex:page standardController="Opportunity" >
    
    <apex:pageBlock title="Opportunities">
        <apex:pageBlockSection>
        <apex:outputField value="{! Opportunity.Account.Name}"/>
        <apex:outputField value="{! Opportunity.Amount }"/>
        <apex:outputField value="{! Opportunity.CloseDate }"/>
        <apex:outputField value="{! Opportunity.Accountid }"/>
        
         </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Please Advise Community!!
Best Answer chosen by Andrew Eversley
Andrew EversleyAndrew Eversley
I thank you Amit for your suggestion, but unfortunately it did not provide the answer. I went back in and re-read the question more thoroughly and found that there are 2 Opportunity names needed to be reflected Opportunity Name and Opportunity Account Name. I made the necessary changes to the code below:

Working Code:
<apex:page standardController="Opportunity">
   
    <apex:pageBlock title="Opportunities">
     <apex:pageBlockSection >
         <apex:outputField value="{! Opportunity.Name}"/>
         <apex:outputField value="{! Opportunity.Amount}"/>
         <apex:outputField value="{! Opportunity.CloseDate}"/>
         <apex:outputField value="{! Opportunity.Account.Name}"/>
       
      </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

All Answers

Andrew EversleyAndrew Eversley
I thank you Amit for your suggestion, but unfortunately it did not provide the answer. I went back in and re-read the question more thoroughly and found that there are 2 Opportunity names needed to be reflected Opportunity Name and Opportunity Account Name. I made the necessary changes to the code below:

Working Code:
<apex:page standardController="Opportunity">
   
    <apex:pageBlock title="Opportunities">
     <apex:pageBlockSection >
         <apex:outputField value="{! Opportunity.Name}"/>
         <apex:outputField value="{! Opportunity.Amount}"/>
         <apex:outputField value="{! Opportunity.CloseDate}"/>
         <apex:outputField value="{! Opportunity.Account.Name}"/>
       
      </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
This was selected as the best answer
Oscar Alejandro Garcia BenitezOscar Alejandro Garcia Benitez
I hope that will help you
<apex:page standardController="Opportunity">
    <apex:pageBlock title="Opportunity Details">
    	<apex:pageBlockSection>
    		<apex:outputField value="{! Opportunity.Name }"/>
    		<apex:outputField value="{! Opportunity.Amount }"/>
    		<apex:outputField value="{! Opportunity.CloseDate }"/>
    		<apex:outputField value="{! Opportunity.Account.Name }"/>
        </apex:pageBlockSection>
	</apex:pageBlock>
</apex:page>

 
Kunal KanaujiyaKunal Kanaujiya
This piece of code is also working.. :)

<apex:page standardController="Opportunity">
    <apex:pageBlock>
        <apex:pageBlockSection>
            <apex:outputField value="{! Opportunity.Name}"/>
            <apex:outputField value="{! Opportunity.Amount}"/>
            <apex:outputField value="{! Opportunity.Closedate}"/>
        </apex:pageBlockSection>
        
        <apex:pageBlockTable value="{! Opportunity.Account}" var="Account">
            <apex:column value="{!Opportunity.Account.name}"/>
        </apex:pageBlockTable>
        
    </apex:pageBlock>
    
    
</apex:page>
Muhammad AlaaMuhammad Alaa
HYG
<apex:page sidebar="false" standardController="Opportunity">
    <apex:pageBlock title="Opportunity View">
        <apex:pageBlockSection>
            <apex:outputField value="{! Opportunity.Name}"/>
            <apex:outputField value="{! Opportunity.Amount}"/>
            <apex:outputField value="{! Opportunity.CloseDate}"/>
            <apex:outputField value="{! Opportunity.Account.Name}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
Praveen ShankarPraveen Shankar
<apex:page standardController="Opportunity">
    <apex:pageBlock title="OPPOURTUNITY">
        <apex:pageBlockSection>
    <apex:outputField value="{!Opportunity.name}" />
    <apex:outputField value="{!Opportunity.Amount}"/>
    <apex:outputField value="{!Opportunity.closedate}"/>
    <apex:outputField value="{!Opportunity.Account.name}"/>
        </apex:pageBlockSection>   
    </apex:pageBlock>
</apex:page>



This code is working and got the points . Can try the above code and look into this for more details
Salesforce AnswersSalesforce Answers
The solution to the "Displaying Records, Fields, and Tables" challenge can be viewed here. ====> https://www.youtube.com/watch?v=RBEPFY4VHxI
Soumya MedepalliSoumya Medepalli
Also include <apex:detail relatedList="false"/> tag
Samir Sayyad 18Samir Sayyad 18

Thanks Muhammad Alaa.!

Your code is working.!!Create a Visualforce page which displays a variety of output fields

Shailendra Sharma 31Shailendra Sharma 31
Hi Oscar Alejandro Garcia Benitez

Currency fields on entities with effective dated currency are not supported. i got this error
dzshannodzshanno
You cant use the OUtputfield component with an Org that has advanced currency management turned on. :-(
Pradeep Reddy 123Pradeep Reddy 123
If you are reciving error "Currency fields on entities with effective dated currency are not supported". Follow these stepes go to Setup>Company Informtaion>Click Currenty setup> Disable Advanced Currency Management is not enabled. It works for me and completed the challange.
Harshit Jain 54Harshit Jain 54
<apex:page standardController="Opportunity">
    <apex:outputField value ="{!Opportunity.Name}"/><br/>
    <apex:outputField value ="{!Opportunity.Amount}"/><br/>
    <apex:outputField value ="{!Opportunity.CloseDate}"/><br/>
    <apex:outputField value ="{!Opportunity.Account.Name}"/>
</apex:page>


This code works. But can anyone please explain how it works? because I went to "field and relationships" tab for "opportunity" object in setup.
I couldn't find any field with name as "account", how is it working? there was one field with lookup relationship to "Account" object, but that was "AccountId" and not Account.
User-added image

Sanyam Choudhary 8Sanyam Choudhary 8

@Harshit Jain 54
Hope This helps
When you will click and open the AccountID it will have the field name as Account.

<apex:page standardController="Opportunity">
 <apex:pageBlock title="Opportunity Details">
    <apex:pageBlockSection>
        <apex:outputField value="{! Opportunity.Name }"/>
        <apex:outputField value="{! Opportunity.Amount }"/>
        <apex:outputField value="{! Opportunity.CloseDate }"/>
        <apex:outputField value="{! Opportunity.Account.Name }"/>
    </apex:pageBlockSection>
 </apex:pageBlock>
</apex:page>

User-added image
Varalakshmi Niharika JaguVaralakshmi Niharika Jagu
Use the below code to get 100% in your challenge!
 
<apex:page standardController="Opportunity">
    <apex:pageBlock title="Opp View">
    	<apex:pageBlockSection>
        	<apex:outputField value="{! Opportunity.Name}"/>
            <apex:outputField value="{! Opportunity.Amount}"/>
            <apex:outputField value="{! Opportunity.CloseDate}"/>
            <apex:outputField value="{! Opportunity.Account.Name}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 
André HenriqueAndré Henrique

In case the error message appears: "ERROR: Currency Fields on entities with effective dated currency are not supported"
Disable Advanced Currency Management and use below code:

 

<apex:page standardController="Opportunity">
    <apex:sectionHeader title="Detalhes da Oportunidade"/>
    <apex:pageBlock title="Informações da Oportunidade">
        <apex:pageBlockSection title="Detalhes Básicos">
            <apex:outputField value="{!Opportunity.Name}"/>
            <apex:outputField value="{!Opportunity.Amount}"/>
            <apex:outputField value="{!Opportunity.CloseDate}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Conta da Oportunidade">
            <apex:outputField value="{!Opportunity.Account.Name}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 

NOTE: The titles are in Portuguese (pt_BR)