How are you my Sitecore Friends? How’s your Sitecore Journey going on? I am here again to share one more small but good to know point about Sitecore. Many things in Sitecore are given by default, but as we are dealing with complex things in our day to day life – we never spend time to look at whether that functionality is given by our Sitecore platform or not and start thinking about custom implementation. Scenario: One such scenario is – How to restrict number of selected items in Sitecore Multilist field? Solution: It is very simple and straight forward. You simply need to go to your template where “Multilist Field” is defined, then add validation expression in “Validation” field as per your need. In my case, validation requirment was to allow maximum three items to be selected. Hence I added validation expression – ^({[^}]+}|?){0,3}$ Also add user friendly message in “Validation Text” field which will be shown to user whenever your field does not meet validation criteria. Below screenshots will help you to understand it easily.
You are interested in this post, but don’t have time to implement and check. Then watch this video which will show you exact implementation.
Have a happy Sitecore Journey!