1.

How To Force Lead Assignment Rule Via Apex While Updating Or Adding The Lead?

Answer»

To ENFORCE ASSIGNMENT Rules in Apex you will need to perform FOLLOWING steps:

1. Instantiate the “Database.DMLOptions” class.
2. Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
3. Finally call a native method on your Lead called “setOptions”, with the Database.DMLOptions instance as the ARGUMENT.

// to turn ON the Assignment Rules in Apex

Database.DMLOptions dmlOptn = new Database.DMLOptions();

dmlOptn.assignmentRuleHeader.useDefaultRule = true;
leadObj.setOptions(dmlOptn);

To enforce Assignment Rules in Apex you will need to perform following steps:

1. Instantiate the “Database.DMLOptions” class.
2. Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
3. Finally call a native method on your Lead called “setOptions”, with the Database.DMLOptions instance as the argument.

// to turn ON the Assignment Rules in Apex

Database.DMLOptions dmlOptn = new Database.DMLOptions();

dmlOptn.assignmentRuleHeader.useDefaultRule = true;
leadObj.setOptions(dmlOptn);



Discussion

No Comment Found