Pages

Wednesday, September 17, 2014

Salesforce: Send Email Alert for Case Comments

Use Case: a team of user (case creator, case creator manager, case owner) need to get email alert when a case comment added to case.

For those who not aware, we can add most recent comment added to the Case in email template
using merge field {!Case.Last_Case_Comment}


Using out-of-the-box feature
Workflow have to trigger from Case Comment object, not from Case object. This mean, email alert also should trigger from Case Comment, not from Case.

1st issue, when user add comment and not marked it as Public, Most Recent Public Case Comment is previous Comment added and mark as public, so that comment will be deliver to user email, which is not correct. We can fix this by adding IsPublished = True into the workflow Rule Criteria, so user will not get email if it is not marked as Public. This is NOT FIT with the needs.

2nd issue, as we use Case Comment as the object in Email Alert, we cannot deliver the email to specific recipients, that information only available in Case level. This is Issue.

Side note: Case comments marked Public will be display in Customer Portal, Self-Service Portal, Chatter Answers, Salesforce to Salesforce. Otherwise, they don't display to those channels.


Here what we did as the workaround:

1. Create a Long Text Area field in Case to store 'Most Recent Public Case Comment' added

2. Create a workflow in Case Comment with Rule Criteria = True; and Evaluate the rule
when a record is: created

3. Create Field Update in Case Comment as action for workflow (step 2), update custom 'Most Recent Public Case Comment' in Case from CommentBody (cross object workflow). This will always bring most recent case comment, regardless it is Public or not.


4. Create another workflow in Case to check if custom {!Case.Last_Case_Comment} is changed - ISCHANGED( Most_Recent_Case_Comment__c )


5. Create Email Alert in Case for Workflow (step 4)
Instead of using standard field {!Case.Last_Case_Comment} in the email template, you need to use the custom field created above (step 1).


Reference:
Creating and Editing Case Comments on Case Detail Pages


1 comment:

Page-level ad