I am creating a dynamic SOSL which finally executed as below when I print in debug:

FIND 'gar,ont2' RETURNING Contact ( Name, FirstName, LastName  WHERE (Preferred_First_Name__c like '%gar%'   OR Preferred_Name_Concatenated__c like '%gar%'   OR ((MiddleName != null OR Two_First_Names__c = true OR Preferred_First_Name__c != null) AND Preferred_Name_Concatenated__c like '%gar%')   OR Login__c like '%gar%'   OR Employee_Id__c like '%gar%) AND Location_Building__c = 'ont2'  ORDER BY Name ASC LIMIT 201)

Error - expecting a right parentheses, found 'ont2'

Can any body help what is wrong with query?

1 Answer 1


There's a missing ' character here:

OR Employee_Id__c like '%gar%)

Must be replaced by:

OR Employee_Id__c like '%gar%')

You must log in to answer this question.

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