I am facing an issue with Case Assingment Rule Email feature. I have a visual force page from where I can create a case, case assignment is working as expected but email is not sending to the target user or queue.
Settings what I have:
- Created a queue and add a user in that queue, enable the checkbox with send email to members.
- Created assignment rule and set the case to created queue in step 1 and choose the desired template.
- Support Settings: Checked Notify Default Case Owner but that sends the generic email when no assignment rule matches. But in case of matching with case assignment rule no email. Case Creation Template (chosen) Case Assigned Template (chosen)
- As I am on sandbox so I enabled these settings too: Email->Deliverability->Access level-> All Email
- Email with process builder and workflow rules is working fine(Tested)
What I noticed, case assignment rule assigns the case to respective queue or user when I see from the case detail page after creation.
Then I thought I should check using APEX class code and that do the same behaviour which as mentioned above such as assign the case to queue or user but no email. Here is the code which I have tried.
//Fetching the assignment rules on case AssignmentRule AR = new AssignmentRule(); AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1]; //Creating the DMLOptions for "Assign using active assignment rules" checkbox Database.DMLOptions dmlOpts = new Database.DMLOptions(); dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id; dmlOpts.EmailHeader.TriggerUserEmail = true; dmlOpts.EmailHeader.triggerAutoResponseEmail = true; List<Case> newCases = new List<Case>(); Case c = new Case(); c.Accountid = '0011w00000lIGLXAA4'; c.Type = 'ICM'; c.Origin = 'Web'; c.Status = 'New'; c.FirstName__c = 'Kamran'; c.LastName__c = 'Jabbar'; newCases.add(c); c.setOptions(dmlOpts); insert newCases;
Can you please guide me on this issue? How can I fix it? I already spent much time on it but no success, if I am missing any configuration, please guide on it. Thank you.