When you add an new field to an object in Salesforce.com, it is possible to check the "Required" checkbox to make it mandatory for every data insert/update. I know it is possible to make it required from a layout, but these conditions are not applied when inserting or updating the database from an Apex code.

Is there a reason why there's no way to do the same with a picklist field?


I don't know if there is a reason why it is not possible, but no, it is not possible to set it required as part of the custom field.

If you absolutely must make it required, provide a default value and/or write a validation rule that verifies that a value is selected on insert and update. This should ensure that a value is always associated to that field.

Here is the validation rule you need:


where Test_Value__c is the API name of your field.

  • How do you plan to check something is filled in with a "workflow rule"... Is that a typo? – eyescream Jan 24 '13 at 16:11
  • Ok, then I'm deleting mine and giving you +1, I thought you're really answering in some harebrained workflow-y way. But ISBLANK works just fine on multiselect picklists ;) – eyescream Jan 24 '13 at 16:15
  • Yes, this is what I am doing right now, using a validation rule. I really don't get it, this should be a built-in feature to preserve data integrity. I'll wait to see if somebody else has another answer to justify the reason behind this. – jpmonette Jan 24 '13 at 16:45
  • I would assume it is related to fact that picklists have the --None-- value when no default option is selected and/or the fact that dependent picklists exit. This is just speculation as I have no idea how they store all of that data under the covers. Hopefully someone else has a good idea of why it isn't base functionality. – Jesse Altman Jan 24 '13 at 16:53
  • --None-- is the value displayed when the field in the database is null. – jpmonette Feb 7 '13 at 20:02

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.