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
PXForcePXForce 

query

When I pass this query in the start ethod of batch process it works fine

 

Database.getQueryLocator([Select Id From Lead Where Isconverted  = : false And Company =: 'ABC' ]);

 

Now if I want to pass it as a string like below then it doesnt work

 

Boolean f = false;

 

String query = 'Select Id,Name From Lead Where IsConverted =\'' + f + '\' And Company =\'' + 'ABC' + '\'';

 

I know i am making some mistake in formatting the string. Please guide me to some documentation that can help resolve this. (format queries as string)

SuperfellSuperfell

boolean's shouldn't be quoted, you need to generate ... isConverted=false, but you're generating isConverted='false'

hisrinuhisrinu

This should work

 

 

String query = 'Select Id,Name From Lead Where IsConverted ='+f+' And Company =\'ABC\'';

PXForcePXForce

So how do you fix it?.

 

If i just say 'IsConverted = false' , it says it doesnt recognize false. Same with 'IsConverted = ' + f + '';