2

Problem: the standard Salesforce "Case transferred to you" mail is ALWAYS being sent, despite the fact that we do not want it.

Description: We have set up Email-to-Case and in the EmailMessage trigger we set some fields of the case correctly and then we update the case:

Database.DMLOptions dmlo = new Database.DMLOptions();
dmlo.EmailHeader.triggerUserEmail = false;
Database.update(cases, dmlo);

In Before Update Case trigger we look for the correct user and assign the case to this user:

if (conditionA) {
    c.OwnerId = ownerA;
} else if (conditionB) {
    c.OwnerId = ownerB;
} // etc.

In Email-to-Case setup we unchecked the "Notify Case Owners on New Emails".
Also, in Support Settings the checkboxes "Notify Default Case Owner" and "Notify Case Owners when Case Ownership Changes" are both unchecked.

And now the funnier part:

  • If we change the case owner manually in Dev console(Execute anonymous), then a notification is NOT sent
  • If we change the case owner in the UI and explicitly say that we do want an email(checkbox), then a notification is NOT sent
  • For a test we hardcoded a new owner id for the cases and tried the Email-to-Case way once again. The owner was set and we did get a notification!
  • Then we also did a dummy update to a record(edit-save), the owner was changed, but the notification was NOT sent!

Did anyone ever see such a weird behaviour? How can we disable these notification mails?

0

The email-to-case context always sends notifications. If you really need to change ownership of the case in a trigger that way, you need to update case ownership in a @future after setting DMLOptions

1
  • Hi. Thanks for the answer. Do you have a link to the docs stating that too? – Novarg Aug 5 '19 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.