+ Start a Discussion
SapamrmSapamrm 

Email alert recipient based on custom field?

I would like to send an email to a non-case-owner each time a new case comment is added.

 

On the force.com discussion board I found a workaround for the problem of generating an email alert from a workflow from case comments. Implementing all the steps suggested by jgreene (his post), I got stuck with the last step 

where the workflow action is created to notify the user of the new case comment: 

 

Add a new workflow action to the above rule:
-Description: "Notify account team of new case comment"
-Email Template: "Case Comment added - notify account team"
-Recipient Type: Account Team
-Recipients:
  Account Team: Primary Sales Engineer
  Account Team: Secondary Sales Engineer

 

My problem is: the person to who I want to send the notification email to can differ for every case. Each case created in our SF environment gets assigned to a specific "case solver", based on the "case type" chosen from a picklist. So the recipient of the email alert depends on the case type. In total there are 8 different case types, thus 8 different possible mail receivers.

 

Ideally, in the "recipients"-field of the email alert workflow action I should be able to add the field "case type" (which is then linked to the case solver and the email address of that user), but that's not an option.

 

Anyone has a suggestion how to tackle this problem?

 

 

Any help is greatly appreciated!

 

SurekaSureka

Hi,

 

I could not think of any out of box solution for this. If you don't have any other option you can go for the below solution.

 

Create 8 workflow rules (one for each case type) and give the recipients accordingly.

 

Hope this works...

 

Thanks

Sureka

 

SargeSarge

Yes. I agree that this is a slightly difficult problem to solve using out-of-the box. However I can think of two approaches

 

1)  This is a little un-gauranteed approach:

 

        a) Create a New field for storing email address of recipient. (of type Email of course); Option is left to you whether or not display it in page layout.

        b)  In the workflow where email alert is to be sent, configure a field update. This field update comes before the Email Alert option. The field update will Update the field value with an email address that is mapped to Case Type field. (Use CASE function in Formula to correctly get the hard coded email address in the formula).

        c) Use this newly created email field in Recipient' s box of the email alert.

 

       Since field update and email alert are in the same workflow, I am not very sure which one will execute first. Hence try this approach at your own risk.

 

2)  This one requires an trigger:

 

       a) Create a New field for storing email address of recipient. (of type Email of course); Option is left to you whether or not display it in the page layout.

       b)  Write a BeforeUpdate trigger that will modify the value of this new Field depending on Case Type. The Email Address to Case Type mapping can be configured in Custom Settings.

       c) Use this Email field in recipient box of the email alert.       

 

Remember, this will only work for a single recipient.

 

 

SapamrmSapamrm

Thanks for the suggestions Sarge.

 

Just like Sureka, I was about to solve it with 8 different workflow rules..

 

 

I gave your first approach a shot, and it seems to be working fine. The field update is triggered first, whereafter the email is sent to the right address.

 

Only problem I still got is: the email should only be sent if the case comment is made by someone else then the case solver. It's no use to get a notification email from a case comment you made yourself.

 

When working with 8 different workflow rules this could be solved using the following rule criteria:

AND( ( LastModifiedBy.LastName__c <> "E.g. last name of the case solver"), ISCHANGED( Last_Case_Comment__c ) )

 

To be honest, I don't see how I can integrate that part (LastModifiedBy.LastName__C is not equal to the case solver) when using only 1 workflow rule?

 

MoosecoutureMoosecouture

Have you looked into using Formula Fields?  You could use a simple field like of the type Formula... IF ( CreatedById =  $User.Id , 1 , 0 ) this will allow you to monitor if the comment is coming from the creator of the case or what have you.  I am not exactly sure what you mean by case solver. 

 

Formula fields are huge you should look into them once I started using them I increased my functionality quite a bit.

BarnesMichaelLBarnesMichaelL
Vote for this idea: https://trailblazer.salesforce.com/ideaView?id=08730000000DqSmAAK