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 

VisualForce TrailHead Error

Create a Visualforce page that uses a custom controller to display a list of cases with the status of 'New'.The page must be named 'NewCaseList'.
The custom controller Apex class must be named 'NewCaseListController'.
The 'NewCaseListController' Apex class must have a publically scoped method named 'getNewCases'.
The 'getNewCases' Apex method should have the return type of 'List' and return a list of case records with the ID and CaseNumber fields and filtered to only have a status of 'New'.
The 'NewCaseList' Visualforce page must use an apex:repeat component which is bound to 'newCases'.
The apex:repeat component must refer to the var attribute as 'case'.
Within the apex:repeat component, bind a apex:outputLink component to the ID of the case so that the page directs the user to the detail page of the respective case record.


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


VisualForce page:

<apex:page controller="NewCaseListController">
  <apex:repeat value="{!newCases}" var="Case">
<li>
<apex:outputLink value="/{!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>
</li>
      
  </apex:repeat>
  
</apex:page>

Custom Contoller:

public class NewCaseListController {

    public static List<Case> getNewCases()
    {
        List<Case> caseList = new List<Case>();
        for(Case ct: [Select Id, CaseNumber FROM Case WHERE Status = 'New'])
            caseList.add(ct);

        return caseList;
    }
}
 
Best Answer chosen by TharunKumar
Neetu_BansalNeetu_Bansal
Hi Tharun,

Remove the keyword 'static' from your method. as there is no need for that.

Let me know, if you need any other help.

Thanks,
Neetu

All Answers

William TranWilliam Tran
Change this:

<apex:outputLink value="/{!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>

to this:

<apex:outputLink value="/{!Case.Id}/e">
  {!Case.CaseNumber}
  </apex:outputLink>

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks
TharunKumarTharunKumar
Tried that but it still shows error.This code takes to edit page for the case record.
Neetu_BansalNeetu_Bansal
Hi Tharun,

Remove the keyword 'static' from your method. as there is no need for that.

Let me know, if you need any other help.

Thanks,
Neetu
This was selected as the best answer