If i am trying to make a SOSL Search Query dynamic where Firstname and Lastname will be coming from remote parameter dynamically. Attached code sample is not working -

enter image description here

But if i make the SOSL Query as hardcode like below, It works perfectly and gives appropriate result. -

searchquery = '';
searchquery = 'FIND {"Jo*" And "Bo*"} IN Name Fields RETURNING Contact(Firstname,Lastname,Title, Account.Name, Phone, Email)';

In the above code "Jo*" is the FirstName and "Bo*" is the Lastname

  • Did you try searchQuery = 'FIND ' + searchQuery + ' IN Name Fields RETURNING ' etc?
    – Patlatus
    Dec 14, 2016 at 10:09

1 Answer 1



searchQuery = 'FIND ' + searchQuery + ' IN Name Fields RETURNING ' 

Please also mark this answer as accepted if this works for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .