You need to sign in to do that
Don't have an account?
Create a Visualforce page displaying new cases
Hi, I am doing Trialhead. But i stuck here. This is my error message:

And my code is:
And my code is:
<apex:page controller="NewCaseListController" showHeader="false"> <apex:form > <apex:pageBlock title="Cases List" id="cases_list"> <apex:pageBlockTable value="{! NewCases }" var="cs"> <apex:outputLink value="{! cs.Id}">{! cs.Id}> <apex:repeat value="{!newCases}" var="case" id="theRepeat"> </apex:repeat> </apex:outputLink> <apex:column value="{! cs.CaseNumber }"/> <apex:column value="{! cs.id }"/> <apex:column value="{! cs.Status}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
All Answers
-----------------------
<apex:page controller="NewCaseListController" showHeader="false">
<apex:repeat value="{!newCases}" var="case" id="theRepeat">
<apex:outputLink value="/!{case.id}">{!case.id}</apex:outputLink>
</apex:repeat>
</apex:page>
CustomController
-------------------------------
public class NewCaseListController {
public List<Case> getNewCases()
{
List<Case> lst = [Select CaseNumber from Case where status='New'];
return lst;
}
}
Apex Class
Hi,
I want to return my result with database.Querry(); method but it is showing error my visualforce page"
An unexpected error has occurred. Your development organization has been notified.". My code for it:-
public class NewCaseListController {
private String val = 'New';
public List<Case> getNewCases() {
List<Case> results = Database.query(
'SELECT Id, CaseNumber FROM Case WHERE Status = \'' + String.escapeSingleQuotes(val)+'\'');
return results;
}
}
The VisualForce Page code using the above controller is as below:
<apex:page controller="NewCaseListController">
<apex:pageblock title="New Cases List" id="cases_list">
<apex:repeat var="case" value="{! newCases }" rendered="true" id="case_list" >
<li>
<apex:outputLink value="/{!case.ID}" >
<apex:outputText value="{!case.CaseNumber}"/>
</apex:outputLink>
</li>
</apex:repeat>
</apex:pageblock>
</apex:page>
With those 2 above, the trailhead challenge was passed. Hopefully it would help.
your code helped me to complete challage.
If you want to use Database.query() then please see the below code -
Hello all,
I am new to this and understand all exept one thing. Why is value="{!NewCases}" in apex:repeat but the method name is getNewCases? How does the page know to call the getNewCases method?
Thank you very much!
Allo,
And then for the NewCaseListController Apex block this should work:Here is the code blocks that I personally used; you're going to want to format it to how you prefer to read it and paste it into your own session, of course. Tabs aren't too friendly when commenting code blocks :)
For the NewCaseList block I put: