You need to sign in to do that
Don't have an account?
Creating & Using Custom Controllers
Hi guys,
1) I need some help sorting out on how to make 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'. My SOQL Where clause does not work as expected.
2) I am getting an error stating: "The page does not include a repeat component", but I am pretty sure that I am using it. Please refer to the Images below
Overall tasks I have performed step-by-step are:
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.
Use this:
private String q3 = 'WHERE Status = \'New\'';
Try writing your method as follows:
Regarding the other error, I am not sure why you are receiving it since you are not using an Apex:Repeat. If you are, please share the updated VF page.
Use <apex:outputLink value = "/{!case.Id}">{!case.CaseNumber}</apex:outputLink>
Thank you guys very much. With your help I was able to solve the problem.
For those who face the same issue please try to use <apex:repeat value="{!newCases}" var="case" id="theRepeat"> as repetion component.
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="Cases List" id="cases_list">
<apex:pageBlockTable value="{! NewCases }" var="cs">
<apex:column >
<apex:outputLink value="/{! cs.Id}">{! cs.Id}>
<apex:repeat value="{! NewCases }" var="case" id="theRepeat">
</apex:repeat>
</apex:outputLink>
</apex:column>
<apex:column value="{! cs.CaseNumber }"/>
<apex:column value="{! cs.Status}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
error:
Challenge not yet complete... here's what's wrong:
The outputLink component is not binding to the ID of a case
<apex:form>
<apex:pageBlock title="Case Lists" id="cases_list">
<apex:pageBlockTable value="{!NewCases}" var="case">
<apex:column>
<apex:outputLink value="{!URLFOR($Action.case.View, case.Id)}" >
{!Case.CaseNumber}
</apex:outputLink>
</apex:column>
<apex:column value="{!case.caseNumber}"/>
<apex:column value="{!case.status}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
If you still get error in completing trailhead
you can use
apex:return value="{!NewCases}" var="case">
after
<apex:pageBlock title="Case Lists" id="cases_list">