You need to sign in to do that
Don't have an account?
Visualforce SOQl
Hi
I am constructing a search page with where condition and order by condition. I have 5 conditions which are selected from the page and for the 6 condition, I always select 'Active' as the value.
For example :
if queryStr contains the query to be executed, this is how its going to be
queryStr= 'Select id, name from products where'
If(other == true)
queryStr+= 'or product_type <> null' etc with other conditions
but the last condition I want is status needs to be active(which is a text data type)
so I tried,
queryStr+= 'and status = 'Active''';
obviously this is not working and I can't figure out a way to do this. I tried assigning Active to a variable and use that in the string but that does not work either.
Pls. help . this is a production issue and I would have to add the active condition so search returns correct value.
I have very limited experience in VF, so this very basic question
Thanks
because the generated soql needs to have the active quoted, e.g.
queryStr += "and status=\'Active\'';
All Answers
The Query already has 4/5 conditions and I want to add a final and to the condition (status = Active) condition
if queryStr contains the query to be executed, this is how its going to be
queryStr= 'Select id, name from products where'
If(other == true)
queryStr+= 'where product_type <> null'
so my querystr will be here
Select id,name from products where product_type_c <> null and also other conditons
now I want the query to look like
Select id,name from products where product_type_c <> null and subtype = '123' and status__c = 'Active'
My querystr has till subtype = 123, but I am struggling to add status__c = 'Active' towards the end.
I tired doing this
QUeryStr += ' and Status__c =' + 'Active' ;
This does not work. I get the following error.
Error: Error occurred while loading a Visualforce page.
Error: unexpected token: 'Active'
Hopefully I am clear otherwise pls. ask me I can explain
because the generated soql needs to have the active quoted, e.g.
queryStr += "and status=\'Active\'';