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
Cheerag VijayaCheerag Vijaya 

Dynamic SOQL Query Search

Hi! I need to write a code using dynamic SOQL query that if I enter either an Account's Name or Phone or Website (any of the three) that Account should be displayed. 
Tejas KardileTejas Kardile
Please refer below blog with sample example of dynamic SOQL with account
http://www.sfdcpoint.com/salesforce/dynamic-soql-query-fetch-fields-object-salesforce/
Amit GhadageAmit Ghadage
Hi Vijaya,
Refer this
public class controller{
List<Account> accList{get;set;}
String searchText {get;set;}

getAccoountList(){
String searchTextTemp =  '%'+searchText +'%';
String QueryString  = 'SELECT Name,Phone,Website FROM Account where name Like  : searchTextTemp  OR  Phone  Like  : searchTextTemp OR Website  Like searchTextTemp ' ;
 accList = database.Query(QueryString  );
}
​}

Best  Reagrds,
Amit Ghadage
Cheerag VijayaCheerag Vijaya
Hi ! I need to enter all the three field values. Its like a combination - though I enter one value or two values or all the three values, it should display the matching results. I need to enter either the Account' s Name or Phone or Website or Name & Phone or Phone & Website or all the three, it should display according to the matching values.