[SalesForce] Case Assignment Rules – Assign to Queue and Email Members – no email sent (Insert by Apex)

Goal:

When a case matches criteria is created assign the Case Owner to "Research Queue" and e-mail queue members.

Current setup:

  1. Queue created for Cases, no distribution email listed (Just Members)
  2. Create Assignment rule to assign Cases to queue based on criteria. Included E-mail Template for Notification

Result:

  1. Case assignment is successful. Case Owners are changed to the desired queue
  2. No e-mail notification is sent to the members

I'm stumped why the e-mails won't go out. It should e-mail each user individually, yet it doesn't.

Update:

The case is inserted via Apex. The Assignment Rule is being queried and set in the DML Options before the insert occurs. The Rule is being fired, the Assignment Rule assigns the owner, but does not do the E-mail notification.

If I manually create the case – bypassing the Apex setup — the Assignment rule also fires AND sends the notification.

AssignmentRule AR = new AssignmentRule(); 
//Assignment Rule Query
AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
//Creating DML Options
Database.DMLOptions dmlOpts = new Database.DMLOptions();
if(AR != null){
   dmlOpts.assignmentRuleHeader.assignmentRuleID = AR.ID;
   mycase.setOptions(dmlOpts);
   insert mycase;  
}

So the Code assigns the Assignment rule (Which returns a valid rule), adds it to my DMlOptions and then sets the options. What else has to happen here?

Best Answer

So the issues turns out to be the DML options.

In order for e-mails to get sent - even from Assignment Rules, the DML option has to be updated:

dmlOpts.EmailHeader.TriggerUserEmail = true;

Otherwise it will ignore any email trying to be sent internally that is not called by apex directly.

Related Topic