How
to force lead assignment rule via Apex while updating or adding the Lead
To enforce Assignment Rules
in Apex you will need to perform following steps:
Instantiate the
“Database.DMLOptions” class.
Set the “useDefaultRule”
property of “assignmentRuleHeader” to True.
Finally call a native method
on your Lead called “setOptions”, with the Database.DMLOptions instance as the
argument.
Example:
// to turn ON the Assignment
Rules in Apex
Database.DMLOptions dmlOptn =
new Database.DMLOptions();
dmlOptn.assignmentRuleHeader.useDefaultRule
= true;
leadObj.setOptions(dmlOptn);
Don't you still have to perform a DML operation of some sort on your lead in order for this to work?
ReplyDelete