Salesforce Certified Platform Developer II — Question 19
A company wants to incorporate a third-party web service to set the Address fields when an Account is inserted, if they have not already been set.
What is the optimal way to achieve this?
Answer options
- A. Create a Process, call an Apex @future(callout=true) method from it, and make the callout from that Apex method.
- B. Create a Process, call an Apex @InvocableMethod from it, and make the callout from that Apex method.
- C. Create an after insert trigger, call an Apex @InvocableMethod method from it, and make the callout from that Apex method.
- D. Create an after insert trigger, call an @future(callout=true) method from it, and make the callout from that Apex method.
Correct answer: D
Explanation
The correct answer is D because using an after insert trigger allows the system to respond immediately after the Account records are created, and calling an @future(callout=true) method ensures that the callout can occur without holding up the transaction. Options A and B are not optimal because they involve Processes which do not suit the requirement as effectively for callouts in this scenario. Option C, while it utilizes an after insert trigger, incorrectly uses an Apex @InvocableMethod, which is not designed for asynchronous operations like callouts.