Plat-Dev-301 practice question 1 of 10
Which use case can be performed only by using asynchronous Apex?
Full set: 160 questionsSalesforce prohibits making synchronous web service callouts directly from an Apex trigger. This restriction is in place to prevent long-running callouts from blocking database operations. To perform a callout after a DML event, the logic must be executed asynchronously. This is achieved by invoking a method annotated with @future(callout=true) or by enqueuing a Queueable Apex job from the trigger. These asynchronous processes run in a separate transaction, allowing the callout to be made without violating governor limits or platform constraints.
A. Querying large datasets can be done synchronously using a SOQL For Loop, which efficiently handles large result sets by batching records and avoiding heap limit errors.
B. Scheduling a future batch process using System.scheduleBatch is an action that can be initiated from a synchronous context, such as an anonymous Apex window or a Visualforce controller.
D. Updating a related record after an insert is a standard use case for an after insert trigger, which operates synchronously within the same transaction as the initial DML operation.
1. Apex Developer Guide, "Triggers and Callouts". This section explicitly states, "You can’t make a callout from a trigger." It then recommends using an asynchronous method (e.g., a future method) to perform the callout.
2. Apex Developer Guide, "Future Methods". The documentation details the use of the @future(callout=true) annotation, which is the primary mechanism for making callouts from trigger logic.
Keep practicing
Take the free Plat-Dev-301 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Plat-Dev-301 practice questions
- Question 2The Account object has a field, Audit_Code__c, that is used to specify what type of audit…
- Question 3How should a developer verify that a specific Account record is being tested in a test cl…
- Question 4There is an Apex controller and a Visualforce page in an org that displays records with a…
- Question 5A developer created and tested a Visualforce page in their developer sandbox, but now rec…
- Question 6Refer to the code below: Lightning Web Component JS file JavaScript import {LightningElem…
- Question 7A developer is developing a reusable Aura component that will reside on an sObject Lightn…
