Salesforce Certified Platform Developer II — Question 222
A company has reference data stored in multiple custom metadata records that represent default information and delete behavior for certain geographic regions.
When a contact is inserted, the default information should be set on the contact from the custom metadata records based on the contact's address information. Additionally, if a user attempts to delete a contact that belongs to a flagged region, the user must get an error message.
What is the optimal way to automate this?
Answer options
- A. Apex invocable method
- B. Remote action
- C. Flow Builder
- D. Apex trigger
Correct answer: D
Explanation
The ideal solution is an Apex trigger because it can execute custom logic before or after a record is inserted or deleted, allowing for the automation of setting default information and enforcing deletion rules based on geographic regions. The other options, such as Flow Builder and Remote action, may not provide the necessary control or timing for these specific requirements, while an Apex invocable method does not automatically respond to DML events like an Apex trigger does.