Newer Version Available
DMLOptions Class
Namespace
Usage
Database.DMLOptions is only available for Apex saved against API versions 15.0 and higher. DMLOptions settings take effect only for record operations performed using Apex DML and not through the Salesforce user interface. The DMLOptions class has three child options.
- DML Child Options
- DmlOptions.AssignmentRuleHeader—Enables setting assignment rule options.
- DmlOptions.DuplicateRuleHeader—Determines options for using duplicate rules to detect duplicate records. Duplicate rules are part of the Duplicate Management feature.
- DmlOptions.EmailHeader—Enables setting email options.
DmlOptions Properties
The following are properties for DmlOptions.
allowFieldTruncation
Signature
public Boolean allowFieldTruncation {get; set;}
Property Value
Type: Boolean
Usage
In Apex saved against API versions previous to 15.0, if you specify a value for a string and that value is too large, the value is truncated. For API version 15.0 and later, if a value is specified that is too large, the operation fails and an error message is returned. The allowFieldTruncation property allows you to specify that the previous behavior, truncation, be used instead of the new behavior in Apex saved against API versions 15.0 and later.
assignmentRuleHeader
Signature
public Database.DmlOptions.Assignmentruleheader assignmentRuleHeader {get; set;}
Property Value
Type: Database.DMLOptions.AssignmentRuleHeader
Usage
emailHeader
Signature
public Database.DmlOptions.EmailHeader emailHeader {get; set;}
Property Value
Type: Database.DMLOptions.EmailHeader
Usage
The Salesforce user interface allows you to specify whether or not to send an email when the following events occur.
- Creation of a new case or task
- Conversion of a case email to a contact
- New user email notification
- Lead queue email notification
- Password reset
In Apex saved against API version 15.0 or later, the Database.DMLOptions emailHeader property enables you to specify additional information regarding the email that gets sent when one of the events occurs because of the code's execution.
localeOptions
Signature
public Database.DmlOptions.LocaleOptions localeOptions {get; set;}
Property Value
Type: Database.DMLOptions.LocaleOptions
Usage
The value must be a valid user locale (language and country), such as de_DE or en_GB. The value is a String, 2-5 characters long. The first two characters are always an ISO language code, for example 'fr' or 'en.' If the value is further qualified by a country, then the string also has an underscore (_) and another ISO country code, for example 'US' or 'UK'. For example, the string for the United States is 'en_US', and the string for French Canadian is 'fr_CA'.
optAllOrNone
Signature
public Boolean optAllOrNone {get; set;}
Property Value
Type: Boolean
Usage
If optAllOrNone is set to true, all changes are rolled back if any record causes errors. The default for this property is false and successfully processed records are committed while records with errors aren't.
This property is available in Apex saved against Salesforce API version 20.0 and later.