0

While creating a picklist or a multipicklist it is unrestricted by default.How do I change the picklist to a restricted picklist?

  • When do you mean by restricted? When and who should it be restricted for? – Girbot Apr 27 '15 at 9:03
  • restricted in the sense,it takes only fixed values.Values other than those given in the picklist field will not be saved.An unrestricted picklist can take a value other than those given in the picklist field. – Bharath Apr 27 '15 at 9:28
1

If you're displaying a picklist field on a standard salesforce page you will not be able to enter any other values apart from the one's available in the picklist. But you can set any values to the picklist if you're setting it from code(apex). AFAIK there's no such setting in salesforce which will prevent it from happening.

To avoid it you can create a validation rule which checks if the value set in the picklist is correct. You could do the same from a trigger if you have some complex logic to allow specific values in special cases.

| improve this answer | |
  • We wrote triggers that do this by enumerating the list of options from the field's describe results. This lets us modify the list with configuration, no validation rule or code to maintain. – sfdcfox Apr 27 '15 at 17:16
1

When you create a picklist it lets you tick a box to select if you want restricted or un-tick if you want unrestricted one.

Later on you can also see in the picklist options "Restrict picklist to the values defined in the value set" is either ticked or unticked.

| improve this answer | |
0

Set multiselect="false" so it will restrict user from select multiple selection.

apex:selectList

| improve this answer | |
  • I didn't mean to restrict user from selecting multiple options,I need a field which does not take values other than those defined in the picklist. – Bharath Apr 27 '15 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.