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
TehNrdTehNrd 

DMLOptions assignmentRuleHeader does not send Queue notification email?

Can anyone confirm that when using the database dml option assigmentRuleHeader.useDefault rule it does not send an email to the owner of the queue in which a lead was assigned?

 

This is some seriously bad news if this is the case.

 

For example, the code below will assign owner ship of lead to correct queue based on assignment rules but the queue members will not be notified there is a new lead in their queue.

 

Lead l = new Lead(LastName='test', Company='test', Website='www.test.com');

database.DMLOptions dmo = new database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
l.setOptions(dmo);
insert l;

 

Is this a bug?

 

Thanks,

Jason

Message Edited by TehNrd on 02-18-2010 03:55 PM
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd

Crisis averted. Bad documentation is to blame here. For these emails to be sent you must use the EmailHeader.triggerUserEmail DML option. Code below works:

 

Lead l = new Lead(LastName='test', Company='user1', Website='www.test.com');

database.DMLOptions dmo = new database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
dmo.EmailHeader.triggerUserEmail = true;
l.setOptions(dmo);
insert l;

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_database_dmloptions.htm?SearchType=Stem

 

Under the emailHeader Method section is says this option allows you to control the following events:

    * Creation of a new case or task
    * Creation of a case comment
    * Conversion of a case email to a contact
    * New user email notification
    * Password reset

 

It should also list Lead Queue email notifications but it does not. Even the notes under triggerUserEmail make no mention of Lead queue notifications.

 

-Jason

 

 

Message Edited by TehNrd on 02-18-2010 04:16 PM

All Answers

TehNrdTehNrd

Crisis averted. Bad documentation is to blame here. For these emails to be sent you must use the EmailHeader.triggerUserEmail DML option. Code below works:

 

Lead l = new Lead(LastName='test', Company='user1', Website='www.test.com');

database.DMLOptions dmo = new database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
dmo.EmailHeader.triggerUserEmail = true;
l.setOptions(dmo);
insert l;

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_database_dmloptions.htm?SearchType=Stem

 

Under the emailHeader Method section is says this option allows you to control the following events:

    * Creation of a new case or task
    * Creation of a case comment
    * Conversion of a case email to a contact
    * New user email notification
    * Password reset

 

It should also list Lead Queue email notifications but it does not. Even the notes under triggerUserEmail make no mention of Lead queue notifications.

 

-Jason

 

 

Message Edited by TehNrd on 02-18-2010 04:16 PM
This was selected as the best answer
jkucerajkucera
Thanks for the heads up Jason - I'll work with our doc team to add Lead Queue's to this help topic.
moniferlomoniferlo

Hi John, can you tell me if it also works with assignment rules where the lead is assigned to a user instead of a queue? We have an assignment rule with an email template selected but the email never gets sent and the only difference I see with this post is that we are using users as assignees instead of queues.

jkucerajkucera

It should work with a user assigned lead as well so I'm guessing your issue is related to something else.

moniferlomoniferlo

Maybe we are missing something regarding the configuration... but the code we use is the same, except for the Database.insert instead of insert, could it have something to do?

 

Lead estudiante = new Lead();

  Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.assignmentRuleHeader.useDefaultRule= true;  
    dmo.EmailHeader.triggerAutoResponseEmail = true;
    dmo.EmailHeader.triggerUserEmail = true;
    estudiante.setOptions (dmo);          
    Database.Saveresult sr = Database.insert(estudiante, false);

 

Furthermore, when we test it from the user interface it works and the email is sent, so the assignment rule and the email template are ok.