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

Assignment rule not fire in case controller extension

I have created custom case page overriding standard functionality through controller extension


and I want to fire assignment rule conditionally


my code is here


public class caseextension
private  Case case1;
public boolean assrulevalue;
public caseextension(ApexPages.StandardController stdController)
this.case1= (Case)stdController.getRecord();

public PageReference save()

AssignmentRule assgn=[Select Name, Id From AssignmentRule  where name='Testassign'];
database.DMLOptions dmo = new database.DMLOptions();
 dmo.AssignmentRuleHeader.useDefaultRule= false;

 insert case1;
//database.insert(case1, dmo);
PageReference pageRef = new PageReference('/' +;
return pageRef;


public boolean getassrule()
    return assrulevalue;
public void setassrule(boolean value)



So what wrong with this code.

Best Answer chosen by Admin (Salesforce Developers) 
What happens if you turn on DMLOptions.EmailHeader.triggerUserEmail?

All Answers

tmatthiesentmatthiesen development is looking into this.  It appears there is an issue with the dmloptions case assignment.  Can you log a case on your end and attach it to this thread?

I am also having same issue. I have built a visualforce Case page based on custom controller and not able make auto assignment work using dmloptions.


This Case page is exposed to customer portal users.


any ETA on when this would be fixed ? any workarounds ? e.g. set a "Assign using active assignment rules" field to true before upserting a case ?




Hi there,


By When Salesforce Development Team is expected to fix this problem?


Any insight will be helpful to know and set expectations with my team & customer.


Thank you,


/Vikas Arora


I guess that's a bit of a relief because I've been going mad with this.  Is there anywhere where have officially acknowledged this in writing where us regular folk can see?  SFDC have a way of taking their sweet time on these sorts of bugs.


Message boards to the rescue!  (well, sort of). 


I was also trying to debug this same issue with some very similar code of my own until I got it in my head to go search on DMLOptions and I found this. tmatthiesen, can you update this board when the bug is fixed?  Thx.

So guys ... any workarounds out there you can suggest?
I have officially logged a bug with my Premier Support rep as this has been driving me nuts too. Hopefully I will get some sort of ETA on a fix and will post it.

I was told that this was scheduled to be fixed last Friday.  It seems to be fixed, but while my assignment rules are assigning properly, they're not sending out the assignment emails.


Maybe it's fixed but only partially??  Anyone else tried this lately and received assignment emails?

What happens if you turn on DMLOptions.EmailHeader.triggerUserEmail?
This was selected as the best answer
Yes!  It now works with dmo.EmailHeader.triggerUserEmail = true;


I'd put on dmo.EmailHeader.triggerAutoResponseEmail = true;


Not quite the same thing!


Wait, you're saying assignmentRuleHeader.useDefaultRule = true works if you also use DMLOptions.EmailHeader.triggerUserEmail = true? Please respond soon - I'm slowly losing my mind.
There are 2 different questions in this thread.  The first was about assignmentRuleHeader.useDefaultRule (which was not working but to my knowledge is fixed now).  The second is about triggering emails.  They're 2 separate settings in DMLOptions.
Here's a snippet of code we just got working for "enhanced web2lead" using Sites. It is firing both the assignment and auto-response rules. There are probably other ways to accomplish this -- but it is working for us.

string id =[Select Name, Id From AssignmentRule where name='Lead Assignment'].id; database.DMLOptions dmo = new database.DMLOptions(); dmo.AssignmentRuleHeader.assignmentRuleId=id; dmo.AssignmentRuleHeader.useDefaultRule= false; dmo.EmailHeader.triggerUserEmail = true; dmo.EmailHeader.triggerAutoResponseEmail = true; NewLead.setOptions(dmo); insert NewLead;



My issue can be found here - i'm trying to use DMLOptions in a trigger: