Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

DmlOptions.AssignmentRuleHeader Class

Enables setting assignment rule options.

Namespace

Database

Example

The following example uses the useDefaultRule option:
1Database.DMLOptions dmo = new Database.DMLOptions();
2dmo.assignmentRuleHeader.useDefaultRule= true;
3
4Lead l = new Lead(company='ABC', lastname='Smith');
5l.setOptions(dmo);
6insert l;
The following example uses the assignmentRuleID option:
1Database.DMLOptions dmo = new Database.DMLOptions();
2dmo.assignmentRuleHeader.assignmentRuleId= '01QD0000000EqAn';
3
4Lead l = new Lead(company='ABC', lastname='Smith');
5l.setOptions(dmo);
6insert l;

DmlOptions.AssignmentRuleHeader Properties

The following are properties for DmlOptions.AssignmentRuleHeader.

assignmentRuleID

Specifies the ID of a specific assignment rule to run for the case or lead. The assignment rule can be active or inactive.

Signature

public Id assignmentRuleID {get; set;}

Property Value

Type: ID

Usage

The ID can be retrieved by querying the AssignmentRule sObject. If specified, do not specify useDefaultRule.

If the value is not in the correct ID format (15-character or 18-character Salesforce ID), the call fails and an exception is returned.

useDefaultRule

If specified as true for a case or lead, the system uses the default (active) assignment rule for the case or lead. If specified, do not specify an assignmentRuleId.

Signature

public Boolean useDefaultRule {get; set;}

Property Value

Type: Boolean

Usage

If there are no assignment rules in the organization, in API version 29.0 and earlier, creating a case or lead with useDefaultRule set to true results in the case or lead being assigned to the predefined default owner. In API version 30.0 and later, the case or lead is unassigned and doesn't get assigned to the default owner.