You need to sign in to do that
Don't have an account?
Brooks Johnson 6
Trailhead Custom Controllers: Unexpected Token.
Hi I am trying to work through the Custom Controller challenge in Trailhead. My VF page is giving me the error :
Visualforce Error
Help for this Page
System.QueryException: unexpected token: ORDER
Class.ContactsListController.getContacts: line 7, column 1
I am not seeing anything wrong with my code. Any thoughts on where I am going wrong?
Visualforce Error
Help for this Page
System.QueryException: unexpected token: ORDER
Class.ContactsListController.getContacts: line 7, column 1
I am not seeing anything wrong with my code. Any thoughts on where I am going wrong?
apex:page controller="ContactsListController"> <apex:form > <apex:pageBlock title="Contacts List" id="contacts_list"> <apex:pageBlockTable value="{! contacts}" var="ct"> <apex:column value="{!ct.FirstName}"/> <apex:column value="{! ct.LastName}"/> <apex:column value="{! ct.Title}"/> <apex:column value="{! ct.Email}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page> public class ContactsListController { private String sortOrder = 'LastName'; public List<Contact> getContacts(){ LIST<Contact> results = Database.query( 'SELECT Id, FirstName, LastName, Title, Email' + 'FROM Contact ' + 'ORDER BY ' + sortOrder + ' ASC ' + 'LIMIT 10' ); return results; } }
All Answers
Hi Brooks,
Please try the below code for VF Page
Please mark it as Best if it helps you.Thanks,
Ajay