You need to sign in to do that
Don't have an account?
Davidvzla
I am trying to create Visualforce page, help please.
Hello friends,
I've been trying to check this challenge but without luck,it is giving me this error: Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: unexpected token: Status.
I don't know what I am doing wrong. Here is my Visualforce page code
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageblock Title="New Case List" id="cases_list">
<apex:repeat var="case" value="{!newCases}">
<apex:outputLink value="/{!case.Id}">
ID: {!case.Id}
</apex:outputLink><br/>
<apex:outputLink value="/{!case.Id}">
Case Number: {!case.CaseNumber}
</apex:outputLink><br/>
</apex:repeat>
</apex:pageblock>
</apex:form>
</apex:page>
and here is my Controller class code:
public class NewCaseListController {
public List<Case> getNewCases() {
List<Case> results = Database.query('Select Id,CaseNumber,Status' +
'From Case' +
'Where Status =\'New\'');
return results;
}
}
Hope someone can help me with this, Thanks a lot.
I've been trying to check this challenge but without luck,it is giving me this error: Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: unexpected token: Status.
I don't know what I am doing wrong. Here is my Visualforce page code
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageblock Title="New Case List" id="cases_list">
<apex:repeat var="case" value="{!newCases}">
<apex:outputLink value="/{!case.Id}">
ID: {!case.Id}
</apex:outputLink><br/>
<apex:outputLink value="/{!case.Id}">
Case Number: {!case.CaseNumber}
</apex:outputLink><br/>
</apex:repeat>
</apex:pageblock>
</apex:form>
</apex:page>
and here is my Controller class code:
public class NewCaseListController {
public List<Case> getNewCases() {
List<Case> results = Database.query('Select Id,CaseNumber,Status' +
'From Case' +
'Where Status =\'New\'');
return results;
}
}
Hope someone can help me with this, Thanks a lot.
All Answers
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 think in the "<apex:outputLink value="/{!case.Id}">" you have used value wrongly. please use like "<apex:outputLink value="case.Id">".
Hope this will help you resolve your problem.
If your problem is solved please mark it based best answer.
Regards
public List<Case> getNewCases() {
List<Case> results = Database.query('Select Id,CaseNumber,Status ' +
' From Case' +
'Where Status =\'New\'');
return results;
}
Please check below post for same issue
1) https://developer.salesforce.com/forums/?id=906F0000000BV8gIAG
2) https://developer.salesforce.com/forums/?id=906F0000000D6NzIAK
3) https://developer.salesforce.com/forums/?id=906F0000000MJCJIA4
OR you can update your apex class like below
Let us know if this will help you
I add your same code and it keeps failing to pass the challenge.
Also it is giving me this error in the Problems tab.
<-- Visualforce Page-->
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="New Case List" id="cases_list">
<apex:repeat value="{!NewCases}" var="case" id="case">
<p><apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink></p>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
<-- Apex Class-->
Public class NewCaseListController {
List<Case> results = new List<Case>();
public List<Case> getNewCases() {
results = [SELECT Id, CaseNumber, Status FROM Case WHERE Status = 'New'];
return results;
}
}
<apex:page controller="NewCaseListController">
<apex:form >
<apex:pageBlock title="New Case List" id="case_list">
<apex:repeat value="{!newCases}" var="case" id="case">
<p> <apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink> </p>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
*************************************************************************
Apex Class Code:
public class NewCaseListController {
public List <Case> getNewCases(){
List<Case> results = new list<Case>();
results = Database.query('SELECT Id, CaseNumber,Status FROM Case WHERE Status = \'New\'' );
return results;
}
}
Output: