There has been some discussion about asking the salesforce.com team to include the CaseComment object in the “triggerable” list. After conferring with JP Seabury (ForceMonkey), we designed a Rube Goldberg-esque solution to the problem.
Whenever a user adds a comment to a case, add him/her to the Case Team.
Here it is, in general terms:
- Workflow on
Case Commentsends email to Apex email service
- Email service parses
UserIdand adds the User to the Case Team
Case Comment Workflow
Use existing workflow functionality to send an email whenever a comment is added to a case.
- Template Includes:
- Case Id
- User Id
The recipient is an Apex email service that we can code using the Email to Idea example by Rasmus Mencke.
For more information on setting up the
InboundEmail object, check the Apex documentation.
The class needs to add the User to the Case Team, which requires a few fields:
MemberId– UserId (received from the email)
ParentId– CaseId (received from the email)
TeamRoleId– Could be hardcoded or found in a SOQL SELECT statement. A better practice would be to pass the name or
Idin the email (coding it in the template), allowing the use of one Apex Class with multiple Case workflow email templates.
TeamTemplateMemberId– This is not a createable field. It is only available when Case Team members are added automatically in Salesforce CRM.
That’s it! The unique part of this is that we’re sending an email FROM Salesforce TO Salesforce.
Thinking outside the box – isn’t it more fun?