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
TharunKumarTharunKumar 

Salesforce TrailHead Error

Using a Standard List Controller, create a Visualforce page which displays a list of Accounts with links to their respective record detail pages.The page must be named 'AccountList'.
It must reference the Account standard controller.
It must have a recordSetVar equal to 'accounts'.
It must have a Visualforce apex:repeat component.
The repeater must have the var attribute set to 'a'.
The repeater must use the <li> HTML list tag
The repeater must use the apex:outputLink component to link to the respective record detail page
HINT: Record detail pages can be reached by placing a record ID at the root of the URL (e.g. '/<record id>')

I tried this code i am able to retrieve the records and clicking on each record showing  the detail page of that record.But Still Trail Head is showing error.Can someone guide me if  I am wrong


<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
      <apex:repeat value="{!Accounts}" var="a">
      <li>
       <apex:outputLink value="{!URLFOR($Action.Account.view, a.id)}">{!a.Name}
       </apex:outputLink>
     </li>
   </apex:repeat>
   </apex:pageBlock> 
</apex:page>
 
Best Answer chosen by TharunKumar
Neetu_BansalNeetu_Bansal
Hi Tharun,

As it is mentioned in the hint, that you need to place record Id at the end of url like '/<record id>', that's why you are not able to complete the challenge. Use this:
<apex:page standardController="Account" recordSetVar="accounts">
	<apex:pageBlock title="Accounts">
		<apex:repeat value="{!Accounts}" var="a">
			<li>
				<apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink>
			</li>
		</apex:repeat>
	</apex:pageBlock> 
</apex:page>
Let me know, if you need any other help.

Thanks,
Neetu

All Answers

Neetu_BansalNeetu_Bansal
Hi Tharun,

As it is mentioned in the hint, that you need to place record Id at the end of url like '/<record id>', that's why you are not able to complete the challenge. Use this:
<apex:page standardController="Account" recordSetVar="accounts">
	<apex:pageBlock title="Accounts">
		<apex:repeat value="{!Accounts}" var="a">
			<li>
				<apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink>
			</li>
		</apex:repeat>
	</apex:pageBlock> 
</apex:page>
Let me know, if you need any other help.

Thanks,
Neetu
This was selected as the best answer
Sindhura ManthapuriSindhura Manthapuri
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:form>
    <li> 
        <apex:repeat var="a" value="{!Accounts}">    
            <apex:outputLink value="/{!a.id}">{!a.name}</apex:outputLink><br/>
        </apex:repeat>
    </li>
    </apex:form>
</apex:page>
Stephen F. MurrayStephen F. Murray
Hi Neetu - I tried your code and got the following error: "Challenge not yet complete... here's what's wrong:
The page component does not include the Account standard controller"

Can anyone tell me what I'm doing wrong?
Neetu_BansalNeetu_Bansal
Hello Stephen,

The below line is using standard controller i.e. Account. 
<apex:page standardController="Account" recordSetVar="accounts">
Can you please post your code so I will check.

Thanks,
Neetu
Stephen F. MurrayStephen F. Murray
Thank you so much for your help Neetu. Below is the code that I am attempting to use:

<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
        <apex:repeat value="{!Accounts}" var="a">
            <li>
                <apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink>
            </li>
        </apex:repeat>
    </apex:pageBlock>
</apex:page>

As you can see, the code ontains a standard controller, yet I am getting the error that I failed to include it.
Neetu_BansalNeetu_Bansal
Hello Stephen,

Sometimes it happens that the code is not throwing the correct error, if possible, can I get access for sometime to analyse this issue. You can share the details personally with me at neetu.bansal.5@gmail.com

Thanks,
Neetu
Stephen F. MurrayStephen F. Murray
Thanks for the heads up. I tried it in a different sandbox and the code worked.
Paresh KoshtiParesh Koshti
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
        <apex:repeat value="{!Accounts}" var="a">
            <li>
                <apex:outputLink value="/{!a.id}">
                    <apex:outputField  value="{!a.Name}"/></apex:outputLink>
                
                </li>
        </apex:repeat>
    </apex:pageBlock> 
</apex:page>
Monika Pawar 9Monika Pawar 9
Try This-: It will really help you to complete YOUR CHALLENGE

<apex:page standardController="Account" recordSetVar="accounts">
    <apex:repeat value="{!accounts}" var="a" id="theRepeat">
    <li><apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink></li>
    </apex:repeat>
</apex:page>
Sravs PotlapalliSravs Potlapalli
<apex:outputLink value="/{!a.id}">{!a.name}

Can some one explain me  why "/" is used before {!a.id} ?
German Romano AlvarezGerman Romano Alvarez
I think "/" it's because it's a URL but I'm not really sure.
German Romano AlvarezGerman Romano Alvarez
I think that we need use "/"  because it's a URL but I'm not really sure.