Skip to content

The Dml.Request Class

GitHub Action edited this page Nov 11, 2025 · 5 revisions

Represents the parameters that the framework uses to process each DML statement. All requests include the records being processed, the DML operation being processed, and additional/optional configuration details.

This type cannot be manually constructed, and all of its properties are read-only. The framework auto-generates a Dml.Request object whenever you call a DatabaseLayer.Dml method.

Properties:

All properties are read-only, and optional unless otherwise otherwise stated:

Property Name Data Type Details
accessLevel System.AccessLevel Determines if the DML operation is processed via SYSTEM_MODE or USER_MODE. Defaults to USER_MODE.
accessLevelName String Outputs the name of the accessLevel property in JSON, since System.AccessLevel objects are not supported in JSON.
deleteCallback String Prints the string-value of the deleteCallback property, which is omitted from JSON since its implementation may or may not be supported in JSON.
saveCallback String Prints the string-value of the saveCallback property, which is omitted from JSON since its implementation may or may not be supported in JSON.
asyncDeleteCallback DataSource.AsyncDeleteCallback A callback object that can optionally be passed to async DML delete methods that support external objects, ex. DatabaseLayer.Dml.doDeleteAsync().
externalIdFieldName String Prints the API Name of the externalIdField.
externalIdField SObjectField An optional primary key field to be used in upsert operations.
isMockDml Boolean True if the request was processed using DatabaseLayer.useMocks(). Else, always False.
isOperationAsync Boolean True for async DML methods that support external objects, like DatabaseLayer.Dml.doInsertAsync(). Else, always False.
isOperationImmediate Boolean True for synchronous DML methods that support external objects, like DatabaseLayer.Dml.doInsertImmediate(). Else, always False.
leadsToConvert List<Database.LeadConvert> Leads to be converted; only present in a DO_CONVERT operation.
numRecords Integer Outputs the number of records being processed. This can be useful, since records and leadsToConvert are always omitted from JSON output to conserve resources.
operation Dml.Operation The type of DML operation being processed. This is always present.
options Database.DmlOptions Stores advanced configuration options for the DML operation. The most common property is OptAllOrNone, which determines if partial failures are allowed.
records List<SObject> The record(s) being processed. This is present in all operations, except DO_CONVERT.
asyncSaveCallback DataSource.AsyncSaveCallback A callback object that can optionally be passed to async DML insert/update methods that support external objects, ex. DatabaseLayer.Dml.doInsertAsync().
sObjectType String Outputs the API Name of the SObjectType being processed, if known. For DO_CONVERT, outputs "Database.LeadConvert". When unknown, outputs "SObject".

JSON-Serialization

For logging purposes, you can safely JSON-serialize the Dml.Request, though Some of the properties of this class may be omitted to save on resources, or because they are not supported in JSON.

Example:

{
	"sObjectType": "Account",
	"options": {
		"OptAllOrNone": true,
		"EmailHeader": {},
		"DuplicateRuleHeader": {},
		"AssignmentRuleHeader": {}
	},
	"operation": "DO_INSERT",
	"numRecords": 1,
	"isOperationImmediate": false,
	"isOperationAsync": false,
	"isMockDml": false,
	"saveCallback": "EmptySaveCallback:[]",
	"deleteCallback": "EmptyDeleteCallback:[]",
	"accessLevelName": "USER_MODE"
}

apex-database-layer

Home

Core Concepts

Reference Guide

Migration Gudes

Clone this wiki locally