Play Games

Search This Blog

Friday, August 19, 2022

query to filter records based on multiselect picklist values in apex salesforce - Salesforce Globe For You

Solution: Use includes in query to filter based on multiselect picklist field with values separated by comma(,) or semicolon (;)

Use semicolon(;) to specify AND operation. Example ('A;B') means record where A and B values are selected.

Use comma (,) to specify OR operation.Example ('A','B') means record where A or B are selected.

Assume Alphabet is a multi select picklist field created on Lead object with values from A to Z 

SOQL query to fetch lead records where A and B multiselect picklist values are selected 

Select id,name from Lead where Alphabet__c includes ('A;B')

Output:

SOQL query to fetch lead records where A or B or both multiselect picklist values are selected 

Select id,name,Alphabet__c from Lead where Alphabet__c includes ('A','B')

Output:



No comments:

Post a Comment