Praxis Academy
Home › Platform Developer II › Process Automation, Logic, and Integration

Platform Developer II practice questions: Process Automation, Logic, and Integration

Process Automation, Logic, and Integration is 27% of the Salesforce Certified Platform Developer II exam. It covers advanced triggers, async Apex, Platform Events, callouts, Named Credentials and Apex web services. Try these 21 free questions, then open each answer to see why every option is right or wrong.

01

A logistics company inserts a Shipment__c record and then, in the same synchronous Apex method, calls an external carrier API with Http.send(). The call fails with "You have uncommitted work pending. Please commit or rollback before calling out." What is the best fix?

  1. Wrap the DML statement in a try/catch block so the callout can proceed.
  2. Call Database.setSavepoint() before the insert so the work is isolated.
  3. Move the callout into a Queueable class that implements Database.AllowsCallouts and enqueue it after the insert.
  4. Increase the callout timeout with req.setTimeout(120000).
Show answer

Answer: C

A. Wrap the DML statement in a try/catch block so the callout can proceed.Catching exceptions does not commit the DML; the pending work still blocks the callout.
B. Call Database.setSavepoint() before the insert so the work is isolated.A savepoint does not commit work; the transaction still has uncommitted DML when the callout runs.
C. Move the callout into a Queueable class that implements Database.AllowsCallouts and enqueue it after the insert. ✓Correct. The Queueable runs in a separate transaction after the DML commits, so the callout is allowed.
D. Increase the callout timeout with req.setTimeout(120000).The error is about pending DML, not about the callout taking too long.

Why: Apex cannot make a callout after DML in the same transaction. Either perform the callout before any DML or move it to asynchronous Apex such as a Queueable with Database.AllowsCallouts or a @future(callout=true) method.

02

An insurance company needs to write an Error_Log__c entry whenever a claim-processing transaction fails. The log must persist even when the transaction is rolled back. Which approach meets this requirement?

  1. Insert the Error_Log__c record inside the catch block before rethrowing the exception.
  2. Publish a platform event configured with Publish Immediately and create the log in a subscriber trigger.
  3. Publish a platform event configured with Publish After Commit and create the log in a subscriber trigger.
  4. Use Database.setSavepoint() and insert the log after Database.rollback().
Show answer

Answer: B

A. Insert the Error_Log__c record inside the catch block before rethrowing the exception.When the exception is rethrown and the transaction rolls back, the inserted log record is rolled back too.
B. Publish a platform event configured with Publish Immediately and create the log in a subscriber trigger. ✓Correct. Events published immediately are not part of the transaction, so they are delivered even if it rolls back, and the subscriber creates the log in its own transaction.
C. Publish a platform event configured with Publish After Commit and create the log in a subscriber trigger.Publish After Commit events are only published if the transaction commits, so a failed transaction would never produce the log.
D. Use Database.setSavepoint() and insert the log after Database.rollback().If the exception still ends the transaction unhandled, the log insert is rolled back as well; this only works when the error is fully handled.

Why: Platform events with the Publish Immediately behavior are published as soon as EventBus.publish() runs, regardless of whether the transaction commits. This makes them ideal for logging failures that cause rollbacks.

03

A healthcare company must notify an external auditing system asynchronously whenever the Status__c field of a Patient_Case__c record changes, without adding logic to the existing synchronous save path. Which solution is most appropriate?

  1. Create a before update trigger that makes a callout with Http.send().
  2. Schedule an Apex job every hour that queries all cases modified since the last run.
  3. Add a custom Status_Changed__c checkbox and poll it from the external system with SOQL.
  4. Enable Change Data Capture for Patient_Case__c and write a change event trigger that checks changedFields in the ChangeEventHeader.
Show answer

Answer: D

A. Create a before update trigger that makes a callout with Http.send().Synchronous callouts are not allowed from triggers, and this adds logic to the save path.
B. Schedule an Apex job every hour that queries all cases modified since the last run.Polling adds delay and extra processing; it does not react to each change as it happens.
C. Add a custom Status_Changed__c checkbox and poll it from the external system with SOQL.This adds fields and polling load instead of an event-driven design.
D. Enable Change Data Capture for Patient_Case__c and write a change event trigger that checks changedFields in the ChangeEventHeader. ✓Correct. Change event triggers run asynchronously after commit, and the header lists which fields changed.

Why: Change Data Capture publishes change events after a record is committed. An Apex trigger on the change event (for example Patient_Case__ChangeEvent) runs asynchronously and can inspect ChangeEventHeader.changedFields to react only to relevant changes.

04

A test method inserts an Account and then calls a method that makes an HTTP callout using a registered HttpCalloutMock. The test fails with "You have uncommitted work pending." Which two changes resolve the error? (Choose 2)

  1. Add @isTest(SeeAllData=true) to the test class.
  2. Perform the Account insert before Test.startTest() and the callout after Test.startTest().
  3. Move the callout into asynchronous Apex such as a Queueable that implements Database.AllowsCallouts, and run it inside Test.startTest()/Test.stopTest().
  4. Replace HttpCalloutMock with StaticResourceCalloutMock.
  5. Call Database.rollback() on a savepoint just before the callout.
Show answer

Answer: B, C

A. Add @isTest(SeeAllData=true) to the test class.Access to org data does not change the rule about DML before callouts.
B. Perform the Account insert before Test.startTest() and the callout after Test.startTest(). ✓Correct. Test.startTest() starts a fresh set of limits and context, so setup DML before it does not block the callout made after it.
C. Move the callout into asynchronous Apex such as a Queueable that implements Database.AllowsCallouts, and run it inside Test.startTest()/Test.stopTest(). ✓Correct. The asynchronous job runs in its own transaction when Test.stopTest() is called, so pending DML does not block it.
D. Replace HttpCalloutMock with StaticResourceCalloutMock.Changing the mock type does not change the rule about DML before a callout.
E. Call Database.rollback() on a savepoint just before the callout.Rolling back would undo the test setup data the method needs.

Why: Even in tests, a callout cannot follow uncommitted DML in the same context. Separating setup DML from the callout with Test.startTest(), or running the callout asynchronously, avoids the error.

05

A developer needs to make a single HTTP callout to a slow tax calculation service from a Queueable job. The service usually responds in about 45 seconds. What happens with the default callout settings?

  1. The callout succeeds because asynchronous Apex has no callout timeout.
  2. The callout times out because the default timeout is 10 seconds; the developer should call req.setTimeout() with a value up to 120,000 milliseconds.
  3. The callout times out because the maximum allowed timeout is 30 seconds.
  4. The callout succeeds only if it is moved to a Continuation inside the Queueable.
Show answer

Answer: B

A. The callout succeeds because asynchronous Apex has no callout timeout.Asynchronous Apex still has callout timeouts; the default applies unless it is changed.
B. The callout times out because the default timeout is 10 seconds; the developer should call req.setTimeout() with a value up to 120,000 milliseconds. ✓Correct. The default callout timeout is 10 seconds, and it can be raised up to a maximum of 120 seconds per callout.
C. The callout times out because the maximum allowed timeout is 30 seconds.The maximum timeout is 120 seconds, so a 45-second response can be supported.
D. The callout succeeds only if it is moved to a Continuation inside the Queueable.Continuations are for UI-initiated requests from Visualforce, Aura or LWC, not for Queueable jobs.

Why: Each HTTP callout has a default timeout of 10 seconds, adjustable with setTimeout() up to 120 seconds. The total time of all callouts in a transaction also cannot exceed 120 seconds.

06

A developer wants to throw a business-specific error when a discount exceeds the approved limit. Which declaration compiles and follows Apex rules for custom exceptions?

  1. public class DiscountLimitError extends Exception {}
  2. public class DiscountLimitException extends Exception {}
  3. public class DiscountLimitException implements Exception {}
  4. public interface DiscountLimitException extends Exception {}
Show answer

Answer: B

A. public class DiscountLimitError extends Exception {}Custom exception class names must end with the word Exception, so this does not compile.
B. public class DiscountLimitException extends Exception {} ✓Correct. A custom exception must extend Exception and its name must end with Exception.
C. public class DiscountLimitException implements Exception {}Exception is a class, not an interface, so it must be extended, not implemented.
D. public interface DiscountLimitException extends Exception {}An exception must be a class; an interface cannot extend the Exception class.

Why: In Apex, custom exceptions are classes that extend Exception, and their names must end with Exception. They inherit constructors and methods such as getMessage() and getCause().

07

When a new Employee__c record is created, an Apex trigger must create a User and assign a Permission Set. The trigger fails with a MIXED_DML_OPERATION error. What is the recommended fix?

  1. Change the trigger from after insert to before insert.
  2. Wrap the User insert in System.runAs() inside the trigger.
  3. Move the User creation and permission set assignment into a @future method or Queueable job.
  4. Use Database.insert(user, false) to allow partial success.
Show answer

Answer: C

A. Change the trigger from after insert to before insert.Mixed DML is about combining setup and non-setup objects in one transaction, not about the trigger context.
B. Wrap the User insert in System.runAs() inside the trigger.System.runAs() can only be used in test methods; it is not a fix for production code.
C. Move the User creation and permission set assignment into a @future method or Queueable job. ✓Correct. Doing the setup-object DML in a separate asynchronous transaction avoids mixing it with the Employee__c DML.
D. Use Database.insert(user, false) to allow partial success.Partial success does not change the restriction on mixing setup and non-setup DML.

Why: DML on setup objects such as User, Group or PermissionSetAssignment cannot be combined with DML on non-setup objects in the same transaction. Asynchronous Apex separates them; in tests, System.runAs() can be used.

08

A Queueable job sends invoices to a billing system. If the job fails with an unhandled exception, the team wants to log the failure and retry it automatically. Which feature should the developer use?

  1. A try/catch block around System.enqueueJob() in the calling code.
  2. Database.Stateful on the Queueable class to keep the error count.
  3. A Transaction Finalizer attached with System.attachFinalizer() that checks FinalizerContext.getResult() and enqueues a retry job.
  4. A Schedulable class that runs every minute to look for failed jobs.
Show answer

Answer: C

A. A try/catch block around System.enqueueJob() in the calling code.The calling transaction finishes before the job runs, so it cannot catch exceptions thrown inside the job.
B. Database.Stateful on the Queueable class to keep the error count.Database.Stateful is a Batch Apex interface and does not detect Queueable failures.
C. A Transaction Finalizer attached with System.attachFinalizer() that checks FinalizerContext.getResult() and enqueues a retry job. ✓Correct. A finalizer runs after the Queueable completes, even after an unhandled exception, and can log the error and enqueue a new job.
D. A Schedulable class that runs every minute to look for failed jobs.Polling adds delay and complexity; finalizers react directly to each job outcome.

Why: Transaction Finalizers implement the Finalizer interface and are attached inside a Queueable's execute() method. They run when the job finishes, and FinalizerContext tells whether it succeeded or failed with an unhandled exception.

09

An Apex trigger calls a @future method. Later, a Batch Apex job updates the same records, causing the trigger to fire inside execute(). The batch fails with "Future method cannot be called from a future or batch method." How should the developer fix the trigger logic?

  1. Change the future method to callout=false.
  2. Wrap the call in a try/catch and ignore the exception.
  3. Check System.isBatch() and System.isFuture() and, in those contexts, run the logic synchronously or use a Queueable instead.
  4. Add Database.Stateful to the batch class.
Show answer

Answer: C

A. Change the future method to callout=false.The callout attribute does not change the restriction on calling future methods from batch context.
B. Wrap the call in a try/catch and ignore the exception.The error stops the call; ignoring it means the logic never runs in batch context.
C. Check System.isBatch() and System.isFuture() and, in those contexts, run the logic synchronously or use a Queueable instead. ✓Correct. Detecting the asynchronous context lets the trigger avoid an illegal future call and choose a supported path.
D. Add Database.Stateful to the batch class.Database.Stateful only keeps instance state; it does not allow future calls from batch.

Why: Future methods cannot be invoked from a future or batch context. Code shared by triggers should check System.isFuture() and System.isBatch() (or use Queueable Apex) to remain safe in every context.

10

A developer writes a Schedulable class that runs nightly and directly calls Http.send() to pull exchange rates. The job fails at run time. What is the correct design?

  1. Have execute() enqueue a Queueable job that implements Database.AllowsCallouts, or call a @future(callout=true) method, to perform the callout.
  2. Implement Database.AllowsCallouts on the Schedulable class.
  3. Add the endpoint to Remote Site Settings so the scheduler can reach it.
  4. Change the cron expression to run every hour so each callout is smaller.
Show answer

Answer: A

A. Have execute() enqueue a Queueable job that implements Database.AllowsCallouts, or call a @future(callout=true) method, to perform the callout. ✓Correct. Scheduled Apex does not support synchronous callouts, so the callout must be delegated to asynchronous Apex that allows callouts.
B. Implement Database.AllowsCallouts on the Schedulable class.Database.AllowsCallouts applies to Batch and Queueable Apex; it does not enable synchronous callouts in scheduled Apex.
C. Add the endpoint to Remote Site Settings so the scheduler can reach it.The endpoint may need to be allowed, but scheduled Apex still cannot make the synchronous callout.
D. Change the cron expression to run every hour so each callout is smaller.The frequency of the job does not change the callout restriction.

Why: Scheduled Apex cannot make synchronous callouts. A common pattern is to schedule a class that starts a Queueable, Batch or @future job that is allowed to make callouts.

11

A developer tests a method that enqueues a Queueable job to update related Task records. The assertion that the tasks were updated fails, even though the job works in a sandbox. What is missing from the test?

  1. Enclosing the call to the method in Test.startTest() and Test.stopTest() so the Queueable runs before the assertions.
  2. Calling System.enqueueJob() a second time in the test.
  3. Using @isTest(SeeAllData=true) so the job can see the Task records.
  4. Querying AsyncApexJob and waiting in a loop until the status is Completed.
Show answer

Answer: A

A. Enclosing the call to the method in Test.startTest() and Test.stopTest() so the Queueable runs before the assertions. ✓Correct. Asynchronous jobs enqueued after Test.startTest() run synchronously when Test.stopTest() is called.
B. Calling System.enqueueJob() a second time in the test.Enqueuing again does not make the job run before the assertions.
C. Using @isTest(SeeAllData=true) so the job can see the Task records.The test creates its own data; the problem is that the job has not run yet.
D. Querying AsyncApexJob and waiting in a loop until the status is Completed.Busy waiting does not run the job in a test and can hit CPU limits.

Why: Test.startTest() and Test.stopTest() mark a block of code whose asynchronous work, such as Queueable, future and batch jobs, is executed when Test.stopTest() runs, so assertions afterward see the results.

12

An external warehouse system subscribes to the Order_Released__e high-volume platform event. After a 24-hour network outage, it needs to receive the events it missed. How can it do this?

  1. Query the Order_Released__e object with SOQL for events created during the outage.
  2. Ask Salesforce to resend events from the Event Monitoring log.
  3. Resubscribe through the Pub/Sub API using the replay ID of the last event it processed.
  4. Republish all events from Salesforce using a Batch Apex job.
Show answer

Answer: C

A. Query the Order_Released__e object with SOQL for events created during the outage.Platform event messages cannot be queried with SOQL.
B. Ask Salesforce to resend events from the Event Monitoring log.Event Monitoring logs user activity; it does not replay platform events.
C. Resubscribe through the Pub/Sub API using the replay ID of the last event it processed. ✓Correct. High-volume platform events are retained for 72 hours, so a subscriber can replay from a stored replay ID.
D. Republish all events from Salesforce using a Batch Apex job.Republishing creates duplicate events and requires extra code; replay is the built-in option.

Why: Salesforce retains high-volume platform events for 72 hours. Subscribers using the Pub/Sub API or CometD can store the last replay ID and resume from it to recover missed events.

13

In a change event trigger on AccountChangeEvent, a developer needs to know whether each event came from an update and which Account Ids it affects. Which code reads this information correctly?

  1. event.Id and event.Type__c
  2. Trigger.oldMap.get(event.Id).changeType
  3. event.CreatedById and event.LastModifiedDate
  4. event.ChangeEventHeader.getChangeType() and event.ChangeEventHeader.getRecordIds()
Show answer

Answer: D

A. event.Id and event.Type__cId is the event's own identifier, and there is no standard Type__c field on change events.
B. Trigger.oldMap.get(event.Id).changeTypeChange event triggers do not provide Trigger.oldMap with prior record values.
C. event.CreatedById and event.LastModifiedDateThese fields describe the event, not the type of change or the affected records.
D. event.ChangeEventHeader.getChangeType() and event.ChangeEventHeader.getRecordIds() ✓Correct. The ChangeEventHeader exposes the change type (for example UPDATE) and the list of affected record Ids.

Why: Each change event includes a ChangeEventHeader with fields such as changeType, recordIds, changedFields, entityName and commitUser. A single event can reference several records when the same change was applied to them.

14

A developer sets req.setEndpoint('https://api.weatherhub.example/v2/forecast') directly in Apex, without a Named Credential. The callout fails with "Unauthorized endpoint." What is required?

  1. Add the endpoint to the CSP Trusted Sites list.
  2. Add @RestResource to the class to authorize outbound calls.
  3. Enable the API Enabled permission for the running user.
  4. Register the base URL in Remote Site Settings, or switch to a Named Credential.
Show answer

Answer: D

A. Add the endpoint to the CSP Trusted Sites list.CSP Trusted Sites control which resources Lightning pages can load in the browser, not Apex callouts.
B. Add @RestResource to the class to authorize outbound calls.@RestResource exposes inbound Apex REST endpoints; it does not authorize outbound callouts.
C. Enable the API Enabled permission for the running user.API Enabled controls inbound API access, not outbound Apex callouts.
D. Register the base URL in Remote Site Settings, or switch to a Named Credential. ✓Correct. Apex callouts to a raw URL require a Remote Site Setting, while Named Credential endpoints are authorized automatically.

Why: Salesforce blocks callouts to unknown endpoints. Either add the URL to Remote Site Settings or, preferably, use a Named Credential, which also handles authentication.

15

A Queueable job loops through 150 Account records and makes one HTTP callout per account to enrich data. The job fails partway through. Which governor limit is it most likely exceeding?

  1. The limit of 50 future method calls per transaction.
  2. The limit of 12 MB heap size for asynchronous Apex.
  3. The limit of 100 callouts per transaction.
  4. The limit of 150 DML statements per transaction.
Show answer

Answer: C

A. The limit of 50 future method calls per transaction.The job makes callouts, not future method calls.
B. The limit of 12 MB heap size for asynchronous Apex.Heap could matter for large responses, but the clearer issue is the number of callouts.
C. The limit of 100 callouts per transaction. ✓Correct. A single transaction can make at most 100 callouts, so 150 callouts exceed the limit; the work should be split or the API's bulk endpoint used.
D. The limit of 150 DML statements per transaction.The job makes callouts; DML statements are a separate limit.

Why: Each Apex transaction can make up to 100 HTTP or web service callouts. For larger volumes, split the work across chained Queueable jobs or Batch Apex chunks, or use a bulk API on the external side.

16

A developer generated Apex classes from a supplier's WSDL using WSDL2Apex and now must write unit tests for the code that calls the generated stub. What should the test do?

  1. Implement the WebServiceMock interface, put the fake response in the response map in doInvoke(), and call Test.setMock(WebServiceMock.class, new SupplierMock()).
  2. Implement HttpCalloutMock and return an XML body from respond().
  3. Use StaticResourceCalloutMock with a static resource containing the WSDL.
  4. Call Test.setReadOnlyApplicationMode(true) so the stub returns a default response.
Show answer

Answer: A

A. Implement the WebServiceMock interface, put the fake response in the response map in doInvoke(), and call Test.setMock(WebServiceMock.class, new SupplierMock()). ✓Correct. WebServiceMock is the testing interface for callouts made through WSDL2Apex-generated classes.
B. Implement HttpCalloutMock and return an XML body from respond().HttpCalloutMock is for HttpRequest-based callouts, not for WSDL2Apex stubs.
C. Use StaticResourceCalloutMock with a static resource containing the WSDL.StaticResourceCalloutMock is for HTTP callouts and would return the WSDL, not a service response.
D. Call Test.setReadOnlyApplicationMode(true) so the stub returns a default response.Read-only mode simulates org maintenance; it does not mock web service responses.

Why: For SOAP callouts made through classes generated by WSDL2Apex, tests implement WebServiceMock. The doInvoke() method places a response object in the response map with the key 'response_x'.

17

Two integration jobs update the same Inventory__c records at the same time, and one sometimes overwrites the other's quantity calculation. The developer wants the Apex logic to lock the rows while it reads and updates them. Which query should be used?

  1. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids FOR UPDATE
  2. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids FOR VIEW
  3. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids ALL ROWS
  4. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids WITH SECURITY_ENFORCED
Show answer

Answer: A

A. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids FOR UPDATE ✓Correct. FOR UPDATE locks the returned records until the transaction ends, so other transactions must wait to update them.
B. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids FOR VIEWFOR VIEW updates the LastViewedDate field; it does not lock records.
C. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids ALL ROWSALL ROWS includes deleted and archived records; it does not lock them.
D. SELECT Id, Quantity__c FROM Inventory__c WHERE Id IN :ids WITH SECURITY_ENFORCEDWITH SECURITY_ENFORCED checks field and object access; it does not lock records.

Why: Adding FOR UPDATE to a SOQL query locks the returned records for the rest of the transaction. This prevents race conditions, though other transactions may wait or fail with UNABLE_TO_LOCK_ROW if the lock is held too long.

18

During large data migrations, an admin needs to temporarily disable the automation in an Opportunity trigger framework for one integration user only, without deploying code. Which design supports this?

  1. Comment out the trigger body in production and redeploy it after the migration.
  2. Deactivate the trigger in production from the Setup UI.
  3. Have the handler check a hierarchy custom setting, such as Bypass_Automation__c.getInstance().Disable_Triggers__c, and set it only for the integration user.
  4. Use a static Boolean variable that the admin sets from the Developer Console.
Show answer

Answer: C

A. Comment out the trigger body in production and redeploy it after the migration.This requires deployments and disables the logic for every user.
B. Deactivate the trigger in production from the Setup UI.Triggers cannot be deactivated directly in production from Setup, and this would affect all users.
C. Have the handler check a hierarchy custom setting, such as Bypass_Automation__c.getInstance().Disable_Triggers__c, and set it only for the integration user. ✓Correct. Hierarchy custom settings can be set per user or profile, and the framework can skip logic when the flag is on.
D. Use a static Boolean variable that the admin sets from the Developer Console.Static variables only last for a single transaction and cannot be set by an admin for future transactions.

Why: Trigger frameworks often include a bypass switch stored in a hierarchy custom setting or custom metadata. Hierarchy custom settings resolve values for the running user, then their profile, then the org default.

19

A retail company needs to set a Region__c field on Account based on the BillingState whenever an account is created or edited. The logic is a simple mapping maintained by admins. Which solution is the most efficient and maintainable?

  1. An after-save record-triggered flow that updates the triggering account.
  2. An Apex after update trigger that queries and updates the account again.
  3. A Batch Apex job that runs nightly and sets the region.
  4. A before-save record-triggered flow that sets Region__c on the triggering record.
Show answer

Answer: D

A. An after-save record-triggered flow that updates the triggering account.After-save updates to the same record cause another save and are slower than before-save updates.
B. An Apex after update trigger that queries and updates the account again.This adds code and an extra DML operation for a simple same-record update.
C. A Batch Apex job that runs nightly and sets the region.The region would be wrong until the nightly job runs.
D. A before-save record-triggered flow that sets Region__c on the triggering record. ✓Correct. Before-save flows update fields on the triggering record without an extra DML and are easy for admins to maintain.

Why: For same-record field updates, before-save record-triggered flows (fast field updates) are the most efficient declarative option. Apex is better reserved for complex logic that declarative tools cannot handle well.

20

When a Sales Order is approved, an Apex method publishes Order_Approved__e so a fulfillment system can start picking. If the approval transaction later fails and rolls back, the fulfillment system must not receive the event. Which publish behavior should the event use?

  1. Publish Immediately, so the event is sent as soon as EventBus.publish() runs.
  2. Publish After Commit, so the event is published only if the transaction commits successfully.
  3. Either behavior, because platform events are always rolled back with the transaction.
  4. Neither; a Change Data Capture event must be used instead.
Show answer

Answer: B

A. Publish Immediately, so the event is sent as soon as EventBus.publish() runs.Publish Immediately sends the event even if the transaction later rolls back, which would trigger picking for an order that was not approved.
B. Publish After Commit, so the event is published only if the transaction commits successfully. ✓Correct. With Publish After Commit, the event is discarded when the transaction rolls back.
C. Either behavior, because platform events are always rolled back with the transaction.Events with Publish Immediately are not rolled back with the transaction.
D. Neither; a Change Data Capture event must be used instead.CDC could work for record changes, but a custom event with the right publish behavior meets this business-event requirement.

Why: Platform events have two publish behaviors. Publish After Commit ties the event to a successful commit, which suits business events. Publish Immediately sends the event regardless of the transaction outcome, which suits logging.

21

A Batch Apex job calls an address-verification API once for each Contact in execute(). With the default scope size, every chunk fails on a governor limit. Which change is the most direct fix?

  1. Implement Database.Stateful so callouts are shared across chunks.
  2. Return an Iterable from start() instead of a QueryLocator.
  3. Move the callouts into the finish() method.
  4. Call Database.executeBatch(job, 100) or lower so each execute() call makes no more than 100 callouts.
Show answer

Answer: D

A. Implement Database.Stateful so callouts are shared across chunks.Database.Stateful keeps member variables; it does not reduce the number of callouts per chunk.
B. Return an Iterable from start() instead of a QueryLocator.The start() return type does not change how many callouts are made in each execute() call.
C. Move the callouts into the finish() method.finish() runs only once and would face the same callout limit for all records.
D. Call Database.executeBatch(job, 100) or lower so each execute() call makes no more than 100 callouts. ✓Correct. With one callout per record, a scope of 100 or less keeps each transaction within the 100-callout limit.

Why: Each execute() call is a separate transaction with its own limits. Choosing the scope size to fit per-transaction limits, such as 100 callouts, is a key design decision for callout-heavy batch jobs.

Find out if you're ready to pass

Take the free Platform Developer II diagnostic: 20 questions, no account needed. Then unlock all 300 questions, full practice exams and the study guide.

Start the free diagnosticSee plans

Other sections of this exam