How to Get Records by Multi-Select Picklist in Flow

How to Get Records by Multi-Select Picklist in Flow

A multi-select picklist field allows users to choose multiple values from a predefined list instead of just one. Although it may sound straightforward, there is a big debate on whether to use multi-select picklists in Salesforce environments. This is because multi-select picklist fields have many limitations. Salesforce is aware of this issue too and recently started displaying the multi-select limitations when creating a new field of this type. One of these limitations is using the Get Records element in Flow to get records by multi-select picklist.

Review multi-select picklist limitations

Using the Get Records Element

Let's assume that you have a Contact Type multi-select picklist field on the Contact object. How can you use the Get Records element to get the contacts that have "Owner" in this field?

Technically, you want to get the records that have "Owner" in this field. However, contains operator in Get Records element doesn't work with multi-select picklist fields.

Get Records by Multi-Select Picklist in Flow

Contains is an invalid operator on multi-select picklist fields. Therefore, your flow will fail with this error message.

Invalid Operator Error - Get Records by Multi-Select Picklist

Using the Collection Filter Element to Filter Records by Multi-Select Picklist

Contains operator in Get Records element doesn't work with multi-select picklist fields. However, surprisingly, contains operator in Collection Filter element works with multi-select picklist fields. Therefore, it is possible to get the records and then filter by the multi-select picklist field.

For instance, you can get all the contact records that have a Contact Type value.

Get Contact Records

Then, filter them using the Collection Filter element.

Filter Contact Records

As you can see, it found 11,108 contact records that their contact type contains (includes) "Owner".

Result of the Flow to Get Records by Multi-Select Picklist

Although this workaround solves the issue in most cases, there is an important limitation to keep in mind. If your Get Records element finds more than 50,000 records, your flow will fail due to a governor limit. Therefore, you should make your Get Records element as selective as possible. For instance, get the contacts that have a value in the contact type field, instead of getting all the contacts in the system.

Too many query rows error

1 Comment

Leave a Reply

Your email address will not be published.


*