Multi-Select Picklists

Multi-select picklists are interchangeable with ordinary picklists in queries, except for being prohibited in the ORDER BY clause. SOQL includes two additional features for filtering multi-select picklists, described in the following list:

Image Semicolon AND operator—The semicolon is used to express multiple string literals. For example, 'Java;Apex' means that the multi-select picklist has both Java and Apex items selected in any order. The semicolon notation can be used with the = and != SOQL operators to make assertions about the selected items of multi-select picklists.

Image INCLUDES and EXCLUDES keywords—The INCLUDES and EXCLUDES keywords are followed by comma-separated lists of literal values. The INCLUDES keyword returns records in which the selected values of a multi-select picklist are included in the list of values. The EXCLUDES keyword returns records that match none of the values.

The semicolon notation can be combined with the INCLUDES and EXCLUDES keywords to express any combination of multi-select picklist values.

To try this out, create a multi-select picklist named Requested Skills on the Project object. Run the SOQL statement given in Listing 5.16 using the Force.com IDE’s Schema Explorer. It returns Project records with the multiple selection of Apex, Java, and C# in the Requested Skills field and also records with only Python selected. Populate Project records with matching values to see them returned by the query.

Listing 5.16 SOQL with Multi-Select Picklist


SELECT Id, Name
  FROM Project__c
  WHERE Requested_Skills__c INCLUDES ('Apex;Java;C#', 'Python')


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.59.109