Search code examples
salesforceapex-code

Prevent assignment email when assigning a lead with Apex


I have some code that automatically assigns a Lead to a Queue via a before Update trigger when certain conditions are met. When leads are assigned though the UI, the 'Send Assignment Notification' checkbox is available to specify whether or not to send a notification to the receiving user(Queue in this case).

l.OwnerId = groups.get('Lead Queue').Id;

This is how I am doing the assignment.

Is there any way to control this when assigning via Apex? It seems that by default an email is sent, which results in all members of the Queue receiving an email anytime a lead is auto-assigned to the Queue, which is not ideal.


Solution

  • Have you tried unchecking the "Send Email to Members" box in the Queue setup page? Maybe you need it for other reasons, but in our org, we've unchecked this box on many of our queues because we don't want the emails--just ownership. We use lead views, daily reports, and custom lead alerting for high priority leads instead.

    We're using Marketo heavily for new leads mostly assigned to territory queues. I assume their code uses the API and sets OwnerId very much like your code example. We're not seeing the assignment notification emails plaguing your users though so I do think it's possible.