function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bill FoxBill Fox 

Limit number of item selected from a pick list.

If I have 10 items in a multi-select picklist. How can I limit the number selected to 3?
Reinke, ChrisReinke, Chris
The only way I can think of that would allow you to limit the number of values is through Apex. On a before trigger you could count the number of ';' symbols and compare that with (maxLimit - 1).

trigger maxNumberOfMultiSelectValues on Contact (before insert, before update) {
    for(Contact c: trigger.new) {
        if(c.MultiSelectField__c.countMatches(';') > 2) c.MultiSelectField__c.addError('Limit to three values');
    }
}