Skip to content

DML_Builder.DML_AsyncBuilder ​

Class · Group: DML

Learn it: Fast Start - DML and DML guide

apex
global class DML_Builder.DML_AsyncBuilder

Runs DML in an async job. It groups the registered operations by type and hands them to PROC_ExecuteDML through UTIL_AsynchronousJobLauncher, which picks a Queueable or Batch job to suit the volume. It carries these settings of the parent builder into the job: access mode, partial success, ignoring sharing, expected refusals and the row-lock retry count. The job enforces record sharing unless .bypassSharing() was called. The job itself runs without sharing, so inherited sharing cannot be used.


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();