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
rcravenrcraven 

Apex triggers conflicting with case contact notifications

There is a running issue with standard Salesforce case support settings which notify contacts.  While working cases our support users have the option to send the client contact a notification on case create, update, or resolution.   However, the standard support settings feature breaks when you use *After* Apex Triggers. It also breaks when you use a *Before* Case Comment Trigger that also updates the parent Case.   We've updated almost all of our Apex Triggers to fire as *Before* triggers, and still the issue persists.  In addition, no errors, exceptions or, warnings  are generated in the Apex debug logs to indicate that there is a problem (triggers and apex classes execute as expected, just no email is generated).  Call me crazy, but I believe we should be able to create *After* Apex Triggers without fear of breaking standard Salesforce functionality!

 

The Salesforce support fix suggested is that we use the following DML email Header options when updating these records.  (ex)

 

Database.DMLOptions dlo = new Database.DMLOptions();

dlo.EmailHeader.triggerOtherEmail = true;

Database.update(updateCases, dlo);

 

However, this option ends up sending an email to a contact every time the record is updated regardless of whether or not the support user selected to notify contact or not.  Worse yet, the standard checkbox field to "notify contacts" is not available in the API to allow us to branch this logic.  Another concern we have is even if this did work, would using this email header option cause the emails to count against our mass email limits.

 

So, the work-around is that we re-write the case UI to access a custom "notify contact" field, and use a special trigger with the DML email option, and hope that we don't run into email limits.

 

We've vetted this issue to both Salesforce support and our Salesforce account executive after the fact, and in both cases were told that Salesforce R&D does not see this as a bug?