+ Start a Discussion
MMA_FORCEMMA_FORCE 

Need to know a better way to accomplish this instead of????

I have 4 filters 2 inputtext boxes and 2 picklists on a VF Page and a button.

 

Now my  report works when u pick or type in anyof the forms on the VF and then click Go...

 

My question is how do I write conditions if they pick 2 or more values from the VF page in apex to re-query..

 

I am using Dynamic SOQL and requery function...

 

This works for one filter... How do I make it for 2 or more filters????

 

if(course!='Select a Course'){
qryString = qryString + 'where ' + CourseName + '=' + '\''+ course+'\'';
}
if(teachername!=null){
qryString = qryString + 'where ' + teacher + '=' + '\''+ teachername+'\'';
}
if(studentname!=null){

qryString = qryString + 'where ' + student + '=' + '\''+ studentname+'\'';
}

 

 

 

Message Edited by MMA_FORCE on 03-03-2010 12:56 PM
Best Answer chosen by Admin (Salesforce Developers) 
sunil316sunil316

If all three of your queries are same, you can write like this,

 

if(course!='Select a Course' && teachername!=null && studentname!=null)

{

qryString = qryString + 'where ' + CourseName + '=' + '\''+ course+'\'' And ' + teacher + '=' + '\''+ teachername+'\'' And ' + student + '=' + '\''+ studentname+'\'';

}