DmlOptions.AssignmentRuleHeader Class

Enables setting assignment rule options.

Namespace

Database

Example

The following example uses the useDefaultRule option:
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;

Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);
insert l;
The following example uses the assignmentRuleID option:
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.assignmentRuleId= '01QD0000000EqAn';

Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);
insert 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.
  • 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.

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.