You need to sign in to do that
Don't have an account?
Generating dynamic soql with multiple where clauses
Hello everyone,
I am trying to form a dynamic soql with multiple where clauses like below..
Thanks
I am trying to form a dynamic soql with multiple where clauses like below..
public class SearchClass { @AuraEnabled public static List<Object__c> searchWithInputs(String fromDate, String toDate, List<String> statuses...) { List<Object__c> records = new List<Object__c>(); String query = 'Select Id,..... from Object__c where '; . . . . . . records = Database.query(query); return records; }Here, the method 'searchWithInputs' have multiple input parameters coming from a lightning component client controller. I need to generate the soql query in such a way it will handle different scenario like,
- All input params are not null (no problem with with this one)
- All input params are null (no problem with with this one)
- Only some params are coming and rest are nulls.
Thanks
You can either check the as shown below:
or you can use conditional operator ,so that we dont require many if conditions:
Hope either of this will be useful.
Thanks
Bhargavi.
All Answers
You can either check the as shown below:
or you can use conditional operator ,so that we dont require many if conditions:
Hope either of this will be useful.
Thanks
Bhargavi.