2

Here is the criteria for the question:

• 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. Controller:

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;
    }
}

VFP:

<apex:page controller = "NewCaseListController" >

    <apex:repeat value ="{!newCases}" var="case">


    </apex:repeat> 

</apex:page>

For some reason my apex:page tags aren't showing up in the code above (I do have them)... the issue is I don't know what to do with the repeat tag (last bullet)

  • value="{! URLFOR($Action.Case.View, case.Id) }" is the wrong answer, but should be the right answer as it actually takes you to the detail case when clicked. value="/apex/{!case.Id}" is the right answer, but doesn't take you to the case detail when clicked. So perhaps they want you to hard code the url up to the id, which is ridiculous because that could change, and it's a temporary dev org, which makes the domain and url even more ridiculous to hardcode. – kiko carisse Apr 13 at 4:39
3

Here's part of what you need to sort out. What's the code you'd use to display a single record containing the ID and CaseNumber fields from the list that's returned? You need to encapsulate that code for displaying those fields within your repeat tags using the value assigned to var; the latter being something you've not done correctly.

I recommend you refer to the links provided you in the references given in the challenge. Having gone through Trailhead myself, they generally give you most everything you need either in the module itself or in the references they point you to just above where the challenge begins.

1

First of all you need to correct your apex class public static List getNewCases() should not be static while you return is caseList.it will Resolve the (Challenge Not yet complete... here's what's wrong: Case records were not returned upon calling 'getNewCases'. Either the method does not exist, or it does not return the expected list of cases) error. And second thing for apex:page is that you have to add any input/output Field in repeat tag like --( apex:outputLink value="/{!Case.Id}"> {!Case.Id} ) (please add the right and left angle bracket(<,/>) in input/output field as requirement needed)

Not the answer you're looking for? Browse other questions tagged or ask your own question.