0

We have a custom object, Programs that has several multiselect picklists. One of these is called keywords. When I look in the field I see that the terms are separated by semicolons. I do this to execute the query: keywordsDataList = Database.query(keywordssearchQuery); The query that I am using is: keywordssearchQuery is

SELECT pgm.Id, pgm.Name__c, pgm.Purpose__c, pgm.Type_of_Assistance__c, pgm.Categories__c, pgm.Categories_text__c, pgm.Program_Eligible_Applicant__c, pgm.Program_Eligible_Projects__c, pgm.Application_Process__c, pgm.Available_Funding__c, pgm.Contact__r.Name, pgm.Contact__r.Title, pgm.Contact__r.Department, pgm.Agency__r.Name, pgm.Contact__r.MailingStreet, pgm.Contact__r.MailingCity, pgm.Contact__r.MailingState, pgm.Contact__r.Phone, pgm.Contact__r.Fax, pgm.Contact__r.Email, pgm.Contact__r.MailingPostalCode, pgm.Keywords__c FROM Program__c pgm WHERE (pgm.Keywords__c LIKE '%401K%' ) ORDER BY pgm.Name__c

I get the error message invalid operator on multipicklist field. I am new to salesforce and have no experience in this. I was very happy that I figured out apex:repeat and all my other fields come out fine for all the records returned. The only fields that aren’t working are multiselect picklists. There must be something special I need to do to get those records. Any ideas?


As an aside, I was thinking about using String.escapeSingleQuotes(searchKey) instead of just searchKey (which is 401K in this example) but we have a lot of legit terms (like Alzheimer’s) that we need to search for.

2

You cannot use LIKE operator with Multi-select picklist, instead you need to use INCLUDES operator in your case. Checkout the documentation for details.

1
  • Worked perfectly. Thanks so much!
    – cw-DEO
    Jun 30 '20 at 17:07

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.