[SalesForce] Lead Assignment rules don’t send email when assigned to Queue

Given

  • Lead Assignment Rules configured and active
  • Queue is configured to Send Email to Members
  • Email deliverability is on and members have valid emails

When

  • Assignment rules execute
  • Assignment is to a Queue and assignment rule defines an email template

Then

  • No email is received by queue member(s)

WHY?

Best Answer

There are innumerable answers to this in Trailblazers and Stackexchange with one exception, which was my use case. I've consolidated various answers.

It all depends on what client is causing the assignment rules to run:

Emails will be sent to queue members

Email will not be sent to queue members (although assignment rules execute)

  • Client is Query Editor in Developer Console - Insert Rows / Save Rows sequence (My Use Case)
  • Any Apex that does not set both DmlOptions.AssignmentRuleHeader and DMLOptions.EmailHeader when doing DML on Lead.
  • Workbench Data | Insert a Lead with, in Settings, either Default Assignment Rules checked or specific Assignment Rule Id specified
  • REST client that sets or does not set the Assignment Rule Header. Absence of header means use the default assignment rules.

What threw me was I was simulating a change in Lead Assignment rules that would apply within a Web-to-Lead use case. Rather than using a real Web-to-Lead form, I decided to insert the Lead using the Query Editor in Workbench. The assignment rules ran but no email was ever sent to the queue members. I was kind of surprised the assignment rules ran at all since I knew about the Assignment Rule Header and there's no place to configure its use in Developer Console. So, seeing the rules execute made me assume that the emails would be sent and that Developer Console was handling behind the scenes setting of the appropriate headers. Much time was wasted in futzing around with the email settings on the Queue

Turns out, that while SOAP and Apex support the EmailHeader, REST does not. Web-to-Lead /servlet/servlet.WebToLead must be using SOAP??

So, if trying to simulate Web-to-Lead, use a Web-to-Lead form. The easiest way to do this is generate the form from the UI, save the HTML to your desktop, and then open the file in your browser.