Salesforce Certified Platform Developer II — Question 149
An Apex Trigger creates a Contract record every time an Opportunity record is marked as Closed and Won. This trigger is working great, except (due to a recent acquisition) historical Opportunity records need to be loaded into the Salesforce instance.
When a test batch of records is loaded, the Apex Trigger creates Contract records. A developer is tasked with preventing Contract records from being created when mass loading the Opportunities, but the daily users still need to have the Contract records created.
What is the most extendable way to update the Apex Trigger to accomplish this?
Answer options
- A. Use a Hierarchy Custom Setting to disable the Trigger for the user who does the data loading.
- B. Use a List Custom Setting to disable the Trigger for the user who does the data loading.
- C. Add the Profile Id of the user who does the data loading to the Trigger so the Trigger won't fire for this user.
- D. Add a Validation Rule to the Contract to prevent Contract creation by the user who does the data loading.
Correct answer: A
Explanation
The correct answer is A because using a Hierarchy Custom Setting allows for a flexible and scalable way to control Trigger behavior based on user context, specifically for the user performing the data loading. Options B and C are less ideal as List Custom Settings may not provide the required context for individual users, and hardcoding Profile Ids limits maintainability. Option D is incorrect as a Validation Rule would prevent all Contract creation by that user, which is not the desired outcome.