You need to sign in to do that
Don't have an account?
jvolkov
Querying Multi-Select Picklists
Is it possible to query Multi-Select Picklists to lookup against a Set?
For example:
Instead of this
SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes ('AAA;BBB','CCC')
Can you do something like this?
I get an error when attempting to save this so I'm wondering what the correct syntax, if possible, for something like this would be.
Set<String> singlePicklistSet = new Set<String>(); /*the set of values from a single picklist*/
SELECT Id, MultiPicklist__c from CustObj__c WHERE MultiPicklist__c includes :singlePicklistSet /*is at least one of the values from MultiPicklist__c in the set of values from the single picklist?*/
In my experience, you have to split the set into a delimited string, and then query against that string
All Answers
I don't exactly follow what your use case is trying to achieve, but check out the following blog entry which I think should help:
http://blog.sforce.com/sforce/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html
In my experience, you have to split the set into a delimited string, and then query against that string
BritishBoyWhoShouldBeInCA (:smileywink:) is partially correct. You can't use bind variables in an 'INCLUDES' clause in SOQL So you can't bind to either a Set of a String in the INCLUDES clause.
Your only option is to contruct the SOQL string and use Dynamic SOQL as shown above.
Awesome that worked, only I changed
to
The former was giving an error of unexpected token: AND
Thanks for your help on this!