+ Start a Discussion
DavidvzlaDavidvzla 

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.
Best Answer chosen by Davidvzla
Amit Chaudhary 8Amit Chaudhary 8
Please delete the old classes and create one more time . It look like some version issue is coming

All Answers

DavidvzlaDavidvzla
Sorry, I forgot to add the challenge name is Create a Visualforce page displaying new cases:

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.
 
Rowallim TechnologyRowallim Technology
Hi Davidvzia
 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
DavidvzlaDavidvzla
Nope, it didn't work, but either way thanks for replying !
Amit Chaudhary 8Amit Chaudhary 8
Please add space after status field

    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
Public class NewCaseListController {
List<Case> results = new List<Case>();


private String sortOrder = 'CaseNumber';
public List<Case> getCase() {
    
    results = [SELECT Id, CaseNumber FROM Case WHERE Status = 'New'];

    return results;
    }
}


Let us know if this will help you
 
DavidvzlaDavidvzla
User-added image
I add your same code and it keeps failing to pass the challenge.
Also it is giving me this error in the Problems tab.
Amit Chaudhary 8Amit Chaudhary 8
Please delete the old classes and create one more time . It look like some version issue is coming
This was selected as the best answer
Sachin SavitaSachin Savita
This will definatly gonna work!
<--   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;
    }

}
 
RAJANI SHARMARAJANI SHARMA
Yes it worked for me thanks.
Hariharan ramyaHariharan ramya
VF Page:

<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:

User-added image

 
Balu veerenBalu veeren
Thank u. It helped.