+ Start a Discussion
NoamNoam 

How to build a Dynamic search?

Hey everyone Im trying to implemente a formula which i know exist in SQL queries.

Lets say i want to give the end user the option to decide which field he wants to search. so in the VF page i have a picklist field in which the user can pick the value he want to search or can leave it empty and then get all the options (meaning no filtering is execute).

 

lets say i have field TYPE in the contact and also this is the field i put in the VF page. In sql it looks like this:

 

SELECT....

FROM contacts

WHERE  contact.TYPE like Iif(VF_TYPE != null, VF_region, "*")

 

No Iif function founded for SOQL couldnt manage with doing it in a simple IF condition as well:

IF(IIF(CONDITION, VALUE IF TRUE, VALUE IF FALSE))  {

 

    commands...

 

}

 

 

Any suggestions?

 

Thx in advanced!

Abhi_TripathiAbhi_Tripathi

Hey Manta ,

 

I have written a blog on this, where user can search records on the basis of there field values, user can choose any field, most of the fields are covered in this code.

 

Concept is sames as you want, but not exact, you can take a look at that

 

http://abhithetechknight.blogspot.in/2013/07/dynamic-soql-brief-description.html

NoamNoam

Hey Abhi, thank you for your answer.

Your code id really good but isnt it just to much for actually a simple function.

 

So, i know this command Iif in SQL solve the problem in no time.

 

Do you know any instance of it in soql???