Skip to content

DML_Builder.DML_AsyncBuilder ​

Class

apex
global class DML_Builder.DML_AsyncBuilder

Async DML execution wrapper. Groups registered operations by type and delegates to PROC_ExecuteDML with UTIL_AsynchronousJobLauncher for adaptive async processing. Carries the parent builder's access mode, partial-success, and sharing-bypass dials across the sync-to-async boundary; the job enforces record sharing unless the bypass dial was set, because its without sharing processor frame makes inherited sharing unavailable.


Methods ​

MethodDescription
global void execute()Enqueues the registered DML operations for asynchronous execution.
global DML_Builder.DML_AsyncBuilder withBatchSize(Integer batchSize)Sets the batch size for async processing.

execute ​

apex
global void execute()

Enqueues the registered DML operations for asynchronous execution. Groups records by operation type and launches one async job per type.

Example

apex
DML_Builder.newTransaction()
    .doUpdate(records)
    .allowPartial()
    .async()
    .execute();

withBatchSize ​

apex
global DML_Builder.DML_AsyncBuilder withBatchSize(Integer batchSize)

Sets the batch size for async processing.

Parameters

ParameterTypeDescription
batchSizeIntegerThe number of records to process per batch/queueable execution.

Returns DML_Builder.DML_AsyncBuilder — This DML_AsyncBuilder instance for fluent chaining.

Example

apex
DML_Builder.newTransaction()
    .doDelete(records)
    .async()
    .withBatchSize(200)
    .execute();