Sub topic 7
Picklists, multi-select picklists and global value sets
This chapter assumes you know how to create a custom field in Object Manager and understand the difference between standard and custom fields. It covers the three ways Salesforce stores a fixed list of choices, and the mistakes that make them hard to change.
Picklist versus multi-select picklist
A picklist field lets a user choose exactly one value from a list that an administrator defines. A multi-select picklist lets a user choose several values. Salesforce stores the selections as a single text value with the choices joined by semicolons, such as Golf;Tennis.
That storage format causes most of the trouble with multi-select picklists. Reports, filters and SOQL need special operators. You can't use them as a controlling field in a dependent picklist. In some places, such as list view charts and some automation, they behave differently from single-select picklists.
| Need | Better choice |
|---|---|
| One answer from a fixed list | Picklist |
| Yes or no | Checkbox |
| Several answers, rarely analyzed | Multi-select picklist |
| Several answers, reported on often | A junction object or several checkboxes |
Working with picklist values in code and formulas
Picklist values can't be compared with a plain equals sign in a formula. Use ISPICKVAL:
IF(ISPICKVAL(StageName, "Closed Won"), Amount, 0)In SOQL, multi-select picklists use INCLUDES. A semicolon inside one string means both values must be selected. Separate strings mean either option:
SELECT Id, Name FROM Contact WHERE Interests__c INCLUDES ('Golf;Tennis', 'Chess')This query returns contacts who selected both Golf and Tennis, and contacts who selected Chess.
Global value sets
A global value set is a list of values defined once and shared by several picklist fields, including fields on different objects. If two objects both need a "Region" list, a global value set keeps them identical. Adding a value to the set adds it everywhere.
Use a global value set when the same list appears on more than one field. Use a field-specific list when the values belong to one field only. A field that uses a global value set can't have its values edited on the field itself. You edit the set instead.
flowchart TDCommon errors
- Deleting a value instead of deactivating it. Deleting a value can leave existing records pointing at it. Deactivate values you no longer want to offer. Records that already use them keep the data.
- Expecting a restricted list. By default, API and data imports can write values that are not in the list. Enable "Restrict picklist to the values defined in the value set" if you need strict enforcement.
- Renaming a value and forgetting code. Apex, formulas and flows that compare against the old label stop matching. Search your org for the old value before you rename it.
- Using a multi-select picklist for data you need to count. Aggregating by individual selection is hard. Choose a structure that supports reporting.
Exercise
A team needs to record which of five products a customer owns, and managers will count customers per product in reports. Is a multi-select picklist the best choice? What would you consider instead?
Show answer
Probably not. Multi-select picklists store values as one semicolon-separated string, which makes counting per value awkward. A junction object between Account and a Product object, or one checkbox per product, supports clean reporting. A multi-select picklist is acceptable only if the data is mainly for display.