Salesforce Certified Platform Developer II — Question 64
A company requires an external system to be notified whenever an account is updated. trigger AccountTrigger on Account (after update){ for (Account updatedAccount:Trigger.new)
{ AccountTriggerHelper.notinyxternalSystem(updatedAccount.id); } } public class AccountTriggerHelperfuture(callout=true)
{ public static void notinyxternalSystem(Id accountId){ Account acc = [Select id, name from Account where accountId =
:accountId]; http objectHttp h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('http://example.org/ restService'); req.setMethod('POST'); req.setBody(JSON.serialize(acc)); HttpResponse res = h.send(req); } }
What LimitException could the following code trigger?
Answer options
- A. System.LimitException: Too many future calls
- B. System.LimitException: Too many callouts
- C. System.LimitException: Too many SOQL queries
- D. System.CalloutException: Callout from triggers are currently not supported
Correct answer: A
Explanation
The correct answer is A because the code utilizes a future method to perform a callout, and if the trigger is fired for multiple accounts at once, it could exceed the limit of future calls allowed in a single transaction. Options B and C are incorrect as they pertain to callout limits and SOQL query limits, which are not directly relevant to this specific piece of code. Option D is also incorrect as the code is valid for callouts from triggers, provided they are handled properly.