Thursday 11 October 2012

Email alerts to dynamic recipients for Case Comments using Standard Workflow Email Alert in Salesforce

Introduction:

In my previous post we have seen how we can send email alerts to static recipients for case comments using standard worklfow email alert "http://salesforcefox.blogspot.in/2012/10/email-alerts-for-case-comments-using.html". 

In this post I am going to walk you thru
   - how to send email alerts to dynamic recipients for case comments using standard salesforce feature.


Field Creation:

Create a long text area field in Case object. I would suggest to give the name as "Recent Case Comment" since value in this field is always going to be latest case comment of this case.
 

Create Workflow to Populate "Recent Case Comment" Field:

Step 1: Create workflow rule for Case Comment object. Evaluation criteria would be "created".

Screen shot for reference


Step 2: Create New Field Update action for the created workflow rule. Field to Update = Case objects "Recent Case Comment" field and Value formula = CommentBody.

Screen shot for reference

Step 3: Activate the workflow.


Create Workflow to Send Email Alerts:

Step 1: As a first step create Email Template for sending email alert.

Screen shot for reference




Step 2: Create workflow rule for Case object. Evaluation criteria would be "created or edited".


Screen shot for reference



Step 3: Create New Email Alert action for the created workflow rule. Choose the Email Template which we have created in Step 1. Unless like in the previous post, here recipients could be any persons who are related to that case. For example recipient could be Related Contact / Related User / Related Lead / Account Owner / Email Field (in case object) / Case Owner / Customer Portal User / User / Roles / Public Groups.


Screen shot for reference




Step 4: Activate the workflow rule.


Testing Results:


Once we are done with the above steps we are ready to receive case comment notification dynamically. Below is my testing results. I have highlighted the merge fields results for easy understanding.

Screen shot for reference









Email alerts for Case Comments using Standard Workfow Email Alert in Salesforce

Introduction: 

In this post we are going to see how to send email alerts for Case Comments using standard workflow email alerts.

As most of the salesforce developer's knows
   - Though we can create Workflow Rules for Case Comments object, there is no option for choosing Case Comments object and its fields while creating Email Templates. So they will think that there is no option for sending email alerts for Case Comments using standard Workflow Email Alerts but this is not true.

Even though Case Comments fields are not available in the "Available Merge Fields" section in the Email Templates, we can manually enter Case Comments fields (in the standard merge fields formats) in the email templates, sf will automatically replace all these fields properly and send email alert to the specified email ids.

Create Email Template:

Create sample email template for case comment notification. Assume the email template name as "Case Comment Notification Template". While creating email template you can specify case comment fields using the standard merge field format {!CaseComment.XXXX}. For example, if you would like to display the comment body then merge field would be {!CaseComment.CommentBody}, like wise we can access all case comment fields.
One more cool thing is we can also specify the Case fields. e.g: {!Case.CaseNumber}, {!Case.Subject} and so on... 
Screen shot for reference
 

Create Workflow Rule and Email Alert:

Step 1: Create workflow rule for Case Comment object. Workflow Evaluation Criteria would be "Created".
Step 2: Add "New Email Alert" workflow action to the created workflow rule. While creating new email alert choose already created email template "Case Comment Notification Template" and choose relevant recipients. 
Note: Recipient could be any User / Customer Portal User / Public Groups / Roles.
Step 3: Activate the workflow rule.
Screen shot for reference

Testing Results:

Once we are done with the above steps we are ready to receive case comment notification. Below is my testing results. I have highlighted the merge fields results for easy understanding.

Screen shot for reference


Disadvantages:

As we all know here disadvantage is "We cannot send email alerts to dynamic recipients". Since recipients are chosen statically i.e either User / Public Group / Roles, there is no way to send email alerts dynamically to any user related to Case and so on... 
So the scope of this facility is limited as of now, but if salesforce starts supporting field creation in Case Comment then we will be all set with this feature. 
Yes, I know until then we need some workaround for solving this issue which I will be walking you thru in my next post "Email alerts to dynamic recipients for Case Comments using Standard Workflow Email Alert in Salesforce".