Salesforce Platform Developer I (legacy) — Question 169
A custom picklist field, Food_Preference_c, exists on a custom object. The picklist contains the following options: “Vegan”, “Kosher”, “No Preference”. The developer must ensure a value is populated every time a record is created or updated.
What is the optimal way to ensure a value is selected every time a record is saved?
Answer options
- A. Write an Apex trigger to ensure a value is selected.
- B. Set “Use the first value in the list as the default value” to True.
- C. Mark the field as Required on the object’s page layout.
- D. Mark the field as Required on the field definition.
Correct answer: D
Explanation
The correct answer is D because marking the field as Required in the field definition ensures that a value must be provided before a record can be saved. Options A and C do not enforce this requirement at the database level, and option B only sets a default without guaranteeing a selection is made.