You need to sign in to do that
Don't have an account?
JamesSS
Include quote in query
I am using dynamic query in my code.
My code:
queryString += '( Type__c <= '+mySearch +')';
My error:
System.QueryException: value of filter criterion for field 'Type__c' must be of type string and should be enclosed in quotes
How to include quote in above code?
Hi James,
Try to use below code.
queryString += '( Type__c = \''+mySearch +'\')';
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
All Answers
please post your full soql query
String queryString = 'SELECT Id FROM Account WHERE';
if(mySearch != null)
queryString += '( Type__c = '+mySearch +')';
List<Account> AccountList = new List<Account>();
AccountList = Database.query(queryString);
system.debug(Logginglevel.ERROR,'*******AccountList*********'+AccountList);
My querystring output in log:
SELECT Id FROM Account WHERE Type__c = 2013
My expected output:
SELECT Id FROM Account WHERE Type__c = '2013'
Try this
queryString += '( Type__c = \''+mySearch +'\')';
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Hi James,
Try to use below code.
queryString += '( Type__c = \''+mySearch +'\')';
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator