Skip to main content

Posts

Showing posts with the label LIKE operator in SFDC

How to use Like Operator in SOSL

Hi All, I have already explained about the LIKE operator in my earlier post. http://salesforceworld4u.blogspot.in/2013/08/like-operator-in-salesforce_13.html Some asked how to use Like operator in SOSL, Below is the some code snippet where Like operator being used in SOSL. Lets find account,contact,lead and opportunities records whose name is containing test keyword List<List<SObject>> searchList = [FIND 'Test*' IN ALL FIELDS RETURNING Account (Id, Name WHERE Name LIKE '%test%' limit 10),Contact(Id, Name WHERE Name LIKE '%test%' limit 10),Opportunity(Id, Name WHERE Name LIKE '%test%' limit 10),Lead(Id, Name WHERE Name LIKE '%test%' limit 10)]; Account [] accounts = ((List<Account>)searchList[0]); System.debug('Printing size-- '+accounts.size()); System.debug('Printing size-- '+accounts ); Contact [] contacts = ((List<Contact>)searchList[1]); System.debug('Printing size-- '+contacts....