function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Betre KennaBetre Kenna 

Database.query error. unexpected token: WHERE

Hi All,

I am stuck with this challange 'Create a Visualforce page displaying new cases', could anyone help me?
I am getting this error message: "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: WHERE"
I belive I did the class correctly. Here it is: 
public class NewCaseListController {
    
    public List<Case> getNewCases(){
        List<Case> results = Database.query(
                                'SELECT ID, CaseNumber, Status' +
                                'From Case ' +
                                'WHERE Status = \' New \'' );
        
        return results;
    }
}
Best Answer chosen by Betre Kenna
Jawaad ShahJawaad Shah
Hi Betre

Please can you try and copy and paste the below:

'SELECT Id, CaseNumber, Status ' +
'FROM Case ' +
'WHERE Status = \'New\' '

Thanks, Jawaad

All Answers

Jawaad ShahJawaad Shah
Hi Betre

Please can you try and copy and paste the below:

'SELECT Id, CaseNumber, Status ' +
'FROM Case ' +
'WHERE Status = \'New\' '

Thanks, Jawaad
This was selected as the best answer
Betre KennaBetre Kenna
Hi Jawaad,

thank you very much! I don't know what you did, now it works. Thank you again.

Betre
Jawaad ShahJawaad Shah
Hi Betre

Sorry, i should have explained .... your line 1 should have had a space after status and before the apostophe.

Status'
Status ' 

Can you see the difference now!

Glad it's resolved.

Thanks, Jawaad
Betre KennaBetre Kenna
It works perfectly. Thank you again. Grace and Peace, Betre Kenna