function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

SOQL "like" query on picklists

I can't find a way to find accounts whose value from a picklist START WITH a particular string. That forces me to check for all the possible values that start with it. E.g. we have Merchant: Active, Merchant: Prospective, Merchant: Committed.

It also means the code won't be forward-compatible if we add another Merchant type.

Is there no way to query for all that start with "Merchant", or even INCLUDE "Merchant" would be better than hard-coding all possibilities.

we don't support 'like' on picklists yet.
Have you considered the use of dependent picklists?  That way, when your user selected Merchant in the controlling picklist, the dependent picklist could show a list of values that you could enlarge at will.  You could implement the LIKE functionality by doing a search for Merchant in the controlling picklist.

Not sure if it would apply in your scenario, but thought it was worth suggesting.


If I cant do  category__c LIKE '%value%' Then what are my options for pulling data like this?


the category__c field is a picklist. my users can select 0-15 values for this field. but i need to be able to pull any record that could have value 'x' in category_c. whether category_c = 'x' or 'x;y;z' or 'a;b;c;x;y;x'


what are my options?


Have you begun to support LIKE operations on pickilsts - in some way yet?


You could use IN and NOT IN on picklists.