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
surya singh 9surya singh 9 

I am a beginner : Not able to solve Trailhead challange for-Developer Beginner :Visualforce Basics-Displaying Records, Fields, and Tables-Create a Visualforce page which displays a variety of output fields

I am a  beginner : Not able to solve Trailhead challange for-Developer Beginner :Visualforce Basics-Displaying Records, Fields, and Tables-Create a Visualforce page which displays a variety of output fields
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.

What I had tried is craeted OppView Page with below code:
<apex:page standardController="Opportunity" tabStyle="Opportunity">
    <apex:pageBlock >
        <apex:pageBlockSection title="Opportunity Information">
           Opportunity Name <apex:outputField value="{!opportunity.name}"/>
           Opportunity Amount <apex:outputField value="{!opportunity.amount}"/>
           Opportunity Close Date. <apex:outputField value="{!opportunity.closeDate}"/>
           Opportunity Account Name   <apex:outputField value="{!opportunity.accountId}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 while checking challange got below error
Challenge Not yet complete... here's what's wrong:
The page does not include a apex:outputField component bound to the opportunity account name.

Please suggest
 
Best Answer chosen by surya singh 9
@Karanraj@Karanraj
It is like the cross-object formula field in salesforce you need to get the parent record information so Opportunity.Account.Name will display the name of the related account record.

All Answers

@Karanraj@Karanraj
The last point in the challenge description is "It must have an apex:outputField component bound to the Account Name of the Opportunity." but in your visualforce page code you are displaying the Account Id not the Name of the account record.
surya singh 9surya singh 9
If I use opportunity.account It gives error . by using opportunity.accountId in preview it shows account name. but while checking challange got below error
Challenge Not yet complete... here's what's wrong:
The page does not include a apex:outputField component bound to the opportunity account name.
 
@Karanraj@Karanraj
It is like the cross-object formula field in salesforce you need to get the parent record information so Opportunity.Account.Name will display the name of the related account record.
This was selected as the best answer
surya singh 9surya singh 9
Thanks!! it works
surya singh 9surya singh 9
Hi Karan ,
one more problem (mentioned  below) is still unsolved  . Please help me on this
 I am beginner : Not able to solve Trailhead challange for-Developer Beginner :Process Automation-Automate Basic Business Processes with Process Builder
Sai chand BitraSai chand Bitra
<apex:page standardController="Opportunity">
     <apex:pageBlock title="Opp 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>
mike franklin 10mike franklin 10
Hi Guys:

I have the same code and looked at the video, but am getting the same error message.   looked at the video as well. Can someone help me here:

My Code:

<apex:page sidebar="false" standardController="Opportunity">
    <apex:pageBlock title="Opportunity">
    <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>
Umesh palUmesh pal
Try this code for a solve trailhead problem:

<apex:page standardController="Opportunity">
    <apex:pageBlock>
        <apex:pageBlockSection title="OppView">
        <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>
Derek S.Derek S.
While that worked, I dont understand why the following did not work to solve the challenge as the same data is displayed, I thought it was a shortcut actually, but it doesnt solve the challenge, but looks identical to the above output, with the addition of the hyperlink <a>  and mouse over for account information and click to view account. Seems a little more usable than just the txt.
 
<apex:page standardController="Opportunity" >
 
    <apex:pageBlock title="Opportunity Info">
       <apex:pageBlockSection>
    
           <apex:outputField value="{! Opportunity.Name }" />
           <apex:outputField value="{! Opportunity.Amount }" />
           <apex:outputField value="{! Opportunity.CloseDate }" />
                 <apex:outputField value="{! Opportunity.AccountId }" /> g
     </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>