DML_Builder.DML_AsyncBuilder
Class · Group: DML
Learn it: Fast Start - DML and DML guide
global class DML_Builder.DML_AsyncBuilderRuns 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
| Method | Description |
|---|---|
| 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
global void execute()Enqueues the registered DML operations for asynchronous execution. Groups records by operation type and launches one async job per type.
Example
DML_Builder.newTransaction()
.doUpdate(records)
.allowPartial()
.async()
.execute();withBatchSize
global DML_Builder.DML_AsyncBuilder withBatchSize(Integer batchSize)Sets the batch size for async processing.
Parameters
| Parameter | Type | Description |
|---|---|---|
batchSize | Integer | The number of records to process per batch/queueable execution. |
Returns DML_Builder.DML_AsyncBuilder — This DML_AsyncBuilder instance for fluent chaining.
Example
DML_Builder.newTransaction()
.doDelete(records)
.async()
.withBatchSize(200)
.execute();