You need to sign in to do that
Don't have an account?
Creating & Using Custom Controllers Trailhead Challenge Issue?
Greetings, I cannot seem to get this to work. I have my var set to cs, as it only works with that, rather, as I attempt to set it, I get the error message of var not set correctly. Please advise. Here's the code. The apex code appears correct.
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="Case List" id="Case_list">
<apex:repeat value="{!NewCases}" var="cs">
<table style="width:1000px;">
<tr>
<apex:repeat value="{!NewCases}" var="cs">
<apex:outputLink value="https://na16.salesforce.com/{!cs.Id}">{!cs.CaseNumber}</apex:outputLink>
<apex:outputLink value="{!cs.CaseNumber}">{!cs.CaseNumber}</apex:outputLink>
</apex:repeat>
</tr>
</table>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="Case List" id="Case_list">
<apex:repeat value="{!NewCases}" var="cs">
<table style="width:1000px;">
<tr>
<apex:repeat value="{!NewCases}" var="cs">
<apex:outputLink value="https://na16.salesforce.com/{!cs.Id}">{!cs.CaseNumber}</apex:outputLink>
<apex:outputLink value="{!cs.CaseNumber}">{!cs.CaseNumber}</apex:outputLink>
</apex:repeat>
</tr>
</table>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
One of the challenge requirements is: "The apex:repeat component must refer to the var attribute as 'case'.".
If you change your var to 'case' instead of 'cs' you should be able to pass the challenge. Thanks and hope this helps.
Sandeep
Please try below for this chanllenge
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="Case List" id="Case_list">
<apex:repeat value="{!NewCases}" var="case">
<table style="width:1000px;">
<tr>
<apex:repeat value="{!NewCases}" var="case">
<apex:outputLink value="https://ap2.salesforce.com/{!case.Id}">{!case.CaseNumber}</apex:outputLink>
<apex:outputLink value="{!case.CaseNumber}">{!case.CaseNumber}</apex:outputLink>
</apex:repeat>
</tr>
</table>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public with sharing class NewCaseListController {
public List<Case> getNewCases()
{
List<Case> results =Database.query('SELECT ID, CaseNumber FROM Case LIMIT 10');
return results;
}
}
_____________________________________________________________________
Controller - "NewCaseListController"
public class NewCaseListController {
list<case> newcase = new list<case>();
public list<case> GetNewCases()
{
newcase = [Select Id,CaseNumber from case where status='New'];
return newcase;
}
}
_______________________________________________________________________
VF - 'NewCaseList'
<apex:page controller="NewCaseListController">
<apex:repeat var="case" value="{!NewCases}">
<li>
<apex:outputLink value="/{!case.id}">{!case.id}</apex:outputLink>
{!case.CaseNumber}
</li>
</apex:repeat>
</apex:page>
____________________________________________________________________
Marco
but
what does <apex:outputLink value="{!case.CaseNumber}">{!case.CaseNumber}</apex:outputLink> achieve?
public class NewCaseListController {
public list<case> getNewCases(){
String st='new';
List<case> results = Database.query('select id, CaseNumber from case where status=:st'); //status="new" was giving error sometime
return results;
}
}
Hello MedhanieHabte,
Please try with the below code:
Page:
<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>
Controller
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;
}
}
Please mark it as the best answer if it helps you in any way.
thanks
As your requirement, I have written this code.You want to find all new cases which status are 'new', right?
Please try once this code.
<apex:page controller="NewCaseListController">
<apex:pageblock title="All New Cases List" id="all_cases_list">
<apex:repeat var="case" value="{! newCases }" rendered="true" id="all_cases_list" >
<li>
<apex:outputLink value="/{!case.ID}" >
<apex:outputText value="{!case.CaseNumber}"/>
</apex:outputLink>
</li>
</apex:repeat>
</apex:pageblock>
</apex:page>
Controller-----------
public class NewCaseListController {
public List<Case> getNewCases() {
List<Case> results = Database.query(
'SELECT Id, CaseNumber FROM Case WHERE Status = 'New');
return results;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com