function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OlTuOlTu 

Setting assignmentRuleId DML Option for CASE does not work properly

I have a CASE trigger assigning a specific assignment rule id using DML option.
This trigger works fine, when a user is editing cases.

Here are some lines of code:
-------------------------------------------
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.assignmentRuleId= idCaseAssignementRule;
caseObject.setOptions(dmlOpts);
update caseObject;

The same code does not function if a workflow rule updates the case!
I can see in debug log, that the setting of dml option is running and doing update. But the assignment rule is not fired.

Now, I start the same code in @future. And it's working fine. Assignment rule changed the case owner correctly.

What's happening here? How can I make this code working without @future?
Phillip SouthernPhillip Southern
How many workflow updates are happening after the record is already updating once?  Triggers will not keep firing off, per order of execution if a workflow rule causes multiple updates, before and after triggers are only fired off once after the first workflow update.  So at most trigger will only fire off twice in the transaction.