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
jwoodall1jwoodall1 

VF Remote Objects - multi picklist filtering

I am trying to use javascript remote objects and can't find a way to filter on a multi picklist.  In SOQL, it would be an INCLUDES statement, but I don't think you can use includes in remote objects. Does anyone have an example of setting a multi select picklist value in a where clause in remote objects.
 
coupons.retrieve({limit: 100, where: {Brands__c: {includes: ('brand1','brand2')}}, orderby:[{Name: 'ASC'}]}, function(err, couponRecords){
//process records
}

//Brands__c is a multi select picklist

 
kaustav goswamikaustav goswami
Hi,

Please use like operator. like '%brand1%' or like '%brand2%'

Refer to this link for explanation. It enlists the operators that can be used.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_remote_objects_using_retrieve_query_object.htm

In the backend the multi-select picklists value is stored as a string - brand1;brand2.

So using like should return all those values that have the values brand1 and brand2.

Thanks,
Kaustav
jwoodall1jwoodall1
I get this error when trying to use the like operator:

Error: Error occurred while performing RETRIEVE operation on sobject: Coupon__c with data: {where={Markets__c={like=%Florida%}}} (INVALID_QUERY_FILTER_OPERATOR: 
start_date__c FROM Coupon__c WHERE Markets__c like '%Florida%' LIMIT
                                   ^
ERROR at Row:1:Column:89
invalid operator on multipicklist field)
Jon RiehmJon Riehm
Includes isn't a valid remot object where condition according to the documentation (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_remote_objects_using_retrieve_query_object.htm). 

Try using: 
coupons.retrieve({limit: 100, where: {Brands__c: {in: ['brand1'])}}, orderby:[{Name: 'ASC'}]}, function(err, couponRecords){