Posts

Showing posts with the label Global Search

Salesforce Lightning: Global Search

Image
Today we will have a look at creating a custom global search using Lightning and SOSL. We will use SOSL to query the results from database and show it on the lightning component using the lightning:datatable tag SOSL is preferred over SOQL in use cases where we want to search for a particular keyword across different objects. The return type of SOSL will be a list of list of sobjects.  List<List<sObject>> searchResult = [FIND :searchKey                                             IN ALL FIELDS RETURNING                                             Account (Id, Name, AccountNumber, Website),                                             Contact(Id, Name, Email, MobilePhone),                                             Opportunity(Id, Name, StageName, CloseDate),                                             Lead(Id, Name, Email, Company)]; Lightning datatable was introduced by Salesforce in Winter 18 release. With lightning datatable, now it has become very easy to