0

I have a Query

query = 'Select Id, Name, Email, Phone from Contact  where (Id = ' + cstIdsList + ') ;' + 'Select Id, Name, Primary_Email__c, Phone  from Account where (Id = ' + astIdsList + ') and (RecordType.Name <>  \'Household\') ';

Changing it to SOSL

FIND {map*} IN ALL FIELDS RETURNING Contact  (Id, Name, Email, Phone), Account  (Id, Name, Primary_Email__c, Phone)

Where do i add the cstIdsList for Contact and astIdsList for Account seperately.

1

Place the WHERE Immediately after the field list:

FIND :value 
IN ALL FIELDS
RETURNING Contact (Id, Name, Email, Phone WHERE Id = :cstIdsList),
          Account (Id, Name, Primary_Email__c, Phone WHERE Id = :astIdsList)
  • FIND :value IN ALL FIELDS RETURNING Contact (Id, Name, Email, Phone WHERE FirstName = firstName, MiddleName = middleName, LastName = lastName), Account (Id, Name, Primary_Email__c, Phone WHERE Id = :astIdsList) – Samuel Jackson Oct 19 '16 at 22:26
  • @SamuelJackson If you need multiple filters, use AND instead of commas. – sfdcfox Oct 19 '16 at 22:33
0

But i have a strange requirement. I have to pull 2 different search results. 1 is Exact Match (Works well with AND) 2 is Like Search Results.

Second one is like the below in Dev Console using Text. Search results have to show all the similar results. Like test1, test2, test3 and everything which has test. How can i do it with Variables??

FIND { test} 
IN All Fields 
RETURNING Contact (Id, Name, Email, Phone where  FirstName LIKE '%test%' OR MiddleName LIKE '%test%' OR LastName LIKE '%test%' )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.