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
ForceGuruForceGuru 

Notify case owner on case comment creation

Hi,

 

I want to notify the case owner whenever a new case comment is being added to the case through a Site that has login enabled for customer portal users. Salesforce has a Support Setting for this particular feature which seems to work when we create case comments normally but not through apex code.

 

Can anyone tell me why this isn't working?

Best Answer chosen by Admin (Salesforce Developers) 
Mohith Kumar ShrivastavaMohith Kumar Shrivastava

The email services ,assignment rules as well as all standard platform features through apex expect the DML option to set to operate.

 

This will be implict in case of UI operations inside the salesforce.through API header is not set by default.Hope this helps and you may like to mark answer true to help other users .Thanks

 

All Answers

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

You need to use setDML option as true and check.

 

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

dlo.EmailHeader.triggerAutoResponseEmail = true;

Case ca = new Case(subject='Plumbing Problems', contactid=c.id);

database.insert(ca, dlo);

 

ForceGuruForceGuru

Thanks for your reply!

 

Yes. The notification goes out when I use this EmailHeader -

 

Database.DMLOptions dmlo = new Database.DMLOptions();
dmlo.EmailHeader.triggerUserEmail = true;
Database.insert(oCaseComment, dmlo);

 

where 'oCaseComment' is the case comment that you add...

 

But can anyone explain why this has to be set. If the case support setting has been enabled and even when the 'Send Customer Notification' checkbox is not selected for the case comments that you add normally via a standard case comment page, the case owner gets notified.

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

The email services ,assignment rules as well as all standard platform features through apex expect the DML option to set to operate.

 

This will be implict in case of UI operations inside the salesforce.through API header is not set by default.Hope this helps and you may like to mark answer true to help other users .Thanks

 

This was selected as the best answer