DMLOptions Class

Enables you to set options related to DML operations.

Namespace

Database

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.

DmlOptions Properties

The following are properties for DmlOptions.

allowFieldTruncation

Specifies the truncation behavior of large strings.

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

Specifies the assignment rule to be used when creating a case or lead.

Signature

public Database.DmlOptions.Assignmentruleheader assignmentRuleHeader {get; set;}

Property Value

Type: Database.DMLOptions.AssignmentRuleHeader

Usage

Note

Note

The Database.DMLOptions object supports assignment rules for cases and leads, but not for accounts or territory management.

emailHeader

Specifies additional information regarding the automatic email that gets sent when an events occurs.

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

Specifies the language of any labels that are returned by Apex.

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.'

For a list of the languages that Salesforce supports, see Which Languages Does Salesforce Support? in the Salesforce online help.

optAllOrNone

Specifies whether the operation allows for partial success.

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.