You need to sign in to do that
Don't have an account?
Roger Pavelle
Using ID in SOQL query
I am trying to build an SOQL query inside a custom controller. The query is supposed to return details of a selected record based on the record ID. However, when I run the query I get an error saying "expecting a colon, found 'a0C1a00000115Xd' ". If I put a colon in front of the ID, I get an error saying "Variable does not exist". How can I fix this?
Modify your code liek below it will work .
Let me know if it helps !!
Thanks
Manoj
All Answers
Can you post your query ?
private String selectedID = string.escapeSingleQuotes(':a0C1a00000115Xd');
public Bolete__c getDetail()
{
Bolete__c detailResult = Database.query(
'SELECT Genus__c, Genus2__c, Genus3__c, regionSuspNC__c ' +
'FROM Bolete__c ' +
'WHERE ID = ' + selectedID);
return detailResult;
}
Modify your code liek below it will work .
Let me know if it helps !!
Thanks
Manoj
One more example of you on dynamic query:- http://amitsalesforce.blogspot.in/search/label/Pagination
Please let us know if this will help you.
Thanks
Amit Chaudhary
I think a simple query is appropriate then Database.query or Database.getQueryLocator for scenario like this .