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
MeenakshmiMeenakshmi 

Dynamic SOQL

Hi,

I have 3 input boxes. None of them is mandatory. User can enter value in any of the box and click on Find records button. I understand that dynamic query is the best solution in this scenario. But I am not being able to form accurate query statement. Please suggest me a solution.

crmprocorpcrmprocorp

Hi,

 

Please find the below link it may helps you .

 

 

https://jeffdouglas-developer-edition.na5.force.com/examples/CustomerSearch

 

 

MeenakshmiMeenakshmi

Hi crmprocorp,

Thanks for the link.

Perviously, I could do this using multiple if-else block.

From your link also, I find the same suggestion that different queries for different situations.

Can these queries be replaced with a single or two dynamic query(s)? 


MeenakshmiMeenakshmi

Hi,

Its solved.

I had to build a query string based on some dyamic conditions and then fire

List<sObject> L = Database.query(string);

 

Using a single query string this has been done.

crmprocorpcrmprocorp

Hi Meenakshi,

 

Can you provide code for this one ??