Wednesday, 23 April 2014

Modifying the "New Email on Case" Template in Salesforce

If you are using Email-to-Case on Salesforce, there is a super handy standard feature that will send an e-mail out to the case owner when a new incoming e-mail is filed against one of their cases.

This is an option turned on via Setup > Customize > Cases > Email-to-Case and then checking the box "Notify Case Owners on New Emails.


Then, when an incoming e-mail is detected by your Email-to-Case config and associated with a Case, the owning user will get an e-mail that reads:

An email has been received for case 00003630: Case system test.

Please click the link below to review the new email and respond appropriately.

[https://na13.salesforce.com/02sf00000000000]

NOTE: It is not recommended that you forward this email because its association with the original case may be lost.

and then the body of the email from the customer..

The requirement that led me to end up writing this was to replace the link in the middle of the e-mail for a client, but I can imagine a whole host of reasons this message might want customising in client systems.. but, if you are setting out on that road, like me, you will probably find quite quickly it is not a standard or custom e-mail template that you can edit. It is fixed, and can only be turned on; and off.

So what do you have to do if you want to edit it? You have to turn it off and replicate the functionality.

Turning it off can be done by following the navigation steps above and then de-selecting the checkbox. Now, when a new e-mail enters a case via Email-to-Case, there will be no notification. Now, you need to build a workflow rule to replicate the functionality.

That is not as simple as it sounds though. Here are the steps we will have to go through:

  • Create a workflow rule on Email Message that will be triggered when a new incoming case e-mail is inserted
  • Because Email Message workflows cannot dispatch Email Messages themselves, we will have to do a field update instead, which we perform on the parent Case
  • Add a workflow rule to the Case object to send the owner an e-mail when it is updated by the previous workflow
First we need the field on Case to update; lets make this field a Date field, as it is something we can set with a formula value quite easily and it gives us an audit value that maybe just one day might be useful to someone!

Access your case fields via Setup > Customize > Cases & Fields and click to create a new field. Call the field "Last Emailed" so the API name is Last_Emailed__c and set it's type to "Date/Time"- make it not required and with no default. I would leave field permissions at the defaults, but then remove it from all page layouts (for the moment at least).

Now we have our field, we need to cause it's update, and then effect it's action to dispatch an e-mail. First let's set it, and we are going to do this when a new Email Message is received on a case.

Click through Setup > Create > Workflow & Approvals > Workflow Rules and click to create a new rule.

On the first page, select "Email Message" from the object drop down (this may only be there if Email-to-Case is enabled). Call it something like "Custom Notification Email" and have it fire whenever a record is created. Set your Rule Criteria to be a Formula, and for the formula enter "true" so every message triggers this Workflow.

On the next page of the Workflow, click to add a New Workflow Action and then select New Field Update and populate it as such so that it will update the case field we have just created to the value of the Formula method "NOW()":


Once this is done, and you are presented with the Workflow, here is a catchy step. Click to Edit the field update you have just created, select the check box to "Re-evaluate Workflow Rules afer Field Change" and save it.

Edit: July 2015

Thank you readers for your comments that this stage is no longer possible! I recreated the steps and lo-and-behold, you cannot mark this field update to re-evaluate. How weird.
 
Therefore, we need to find an alternative way to send the e-mail based on this first workflow evaluating. Well seeing as it's now 2015, why not use Process Builder! Process Builder comes later in the order of execution than Workflow, so I can't see why you couldn't create a process based on the same conditions/premise as this post - that sent an e-mail when the Case "Last_Emailed__c" field was updated.

I don't have time right now to test this sorry :( but if anyone has any luck with that route, please let me know in the comments. Just replace the word "Workflow" with "Process builder" for the rest of this article, and the complicated screen shots for the lovely new screenshots that a Process might have!

Resume original post:

Finally, complete the Workflow setup and remember to activate it! This is the most commonly made workflow mistake is forgetting to activate! We now have the second stage of our process complete.

Before we can make our final Workflow rule to dispatch a custom e-mail, we better make sure we have our custom e-mail template ready to use. Click through Setup > Communication Templates > Email Templates and make a new template (the details of the process for which I will not cover here as it is well documented).

Now we can make that final Workflow rule. Go back to Setup > Create > Workflow & Approvals > Workflow Rules and click to create another new rule. This time, we are making it on "Case".

Give you rule a name, and select "created, and every time it's edited" as your evaluation criteria. This time, the rule criteria is important, as we don't want to send an e-mail everytime any change is made to a case, therefore, select the formula criteria entry again, and this time enter

ISCHANGED(Last_Emailed__c)


This means the Workflow will only fire if the "Last_Emailed__c" field has changed from it's previous value (i.e. the first workflow rule caused it).

Once we have this, get into your new Workflow rule, add an Email alert, choose your custom template (this is the point you might want to set off your success fireworks) and pick the "Owner" as the recipient. Fiddle with any other settings you like, then save your Workflow, activate it, and sit back and watch as new incoming e-mails cause the dispatch of a custom notification email to the case owner to inform them of this message.



35 comments:

  1. Great article, I love this functionality in Salesforce.

    ReplyDelete
  2. Blog very attractive.Congratulations! valuable post it was really useful.

    ReplyDelete
  3. Nice article. I think you should check if the EmailMessage is incoming or not. This might fire for emails that are outbound.

    ReplyDelete
    Replies
    1. That's a really good point, and I'm sure I remember it being discussed when we were developing this solution.. but I'm not sure of the outcome, looking back over it now, it definitely looks like there would be some complication surrounding the creation of outbound e-mails. Adding some entry criteria to the first workflow would probably provide a hard-and-fast solution to avoid this. Not sure how/why we are "getting away with it" at the moment though, might be worth investigating if I have a quiet afternoon one day!

      Delete
  4. I tried using your logic to send an email to case related users when a case comment is added. I added the new field on the case but updated it from a workflow rule on the Case Comment object. However, when selecting "Re-evaluate Workflow Rules after Field Change" I get a message that says:

    "Re-evaluate Workflow Rules after Field Change cannot be specified for a parent field update"

    Any way around that? Thanks!

    ReplyDelete
    Replies
    1. I have same problem, got same error, cannot check "re-evaluate"

      Delete
    2. Hi Guys... thanks for your comments. I have reviewed this post now, and my best suggestion is to not set this check box (which you can't!) and instead use a Process Builder process to send the e-mail from the case object update. The firing criteria of the Last_Emailed__c field being updated stands true, just add an e-mail alert to the process instead of doing a workflow. Hope that helps.

      Delete
  5. Me too - I have same problem, got same error, cannot check "re-evaluate"

    ReplyDelete
  6. Hi, Thank you for your comment, it does seem that this is now the case, I have just replicated the scenario. I have added an update (in yellow) in the middle of the post, in which I would now suggest doing the second "action" with a Process instead of workflow? Hopefully this helps. Please let me know if so and/or you need any other specific help (though I am no process expert at the moment!)

    ReplyDelete
  7. Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. ethereum notifications

    ReplyDelete
  8. You have outdone yourself this time. It is probably the best, most short step by step guide that I have ever seen. visit this site

    ReplyDelete
  9. thank you for this such a good information about hotmail email login on www.hotmail.com

    ReplyDelete
  10. Your articles are inventive. i am searching manage to analyzing the plethora of articles which you have comparable right here. Thumbs taking place! Buy Email List

    ReplyDelete
  11. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. lenzuola matrimoniali

    ReplyDelete
  12. It's late finding this act. At least, it's a thing to be familiar with that there are such events exist. I agree with your Blog and I will be back to inspect it more in the future so please keep up your act. hotmail.com

    ReplyDelete
  13. I think this is an informative post and it is very beneficial and knowledgeable. Therefore, I would like to thank you for the endeavors that you have made in writing this article. All the content is absolutely well-researched. Thanks... acesse a caixa de entrada do Hotmail entrar

    ReplyDelete
  14. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. www.hotmail.com entrar

    ReplyDelete
  15. There are several different techniques an internet marketer might use to build his email list. The most legitimate of these is by directly asking you for it. best email extractor from website

    ReplyDelete
  16. Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. DuckDuckGo! Website Scraper Software

    ReplyDelete
  17. I found this is an informative and interesting post so i think so it is very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this article. Lead Generation Software for Small to Enterprise Businesses

    ReplyDelete
  18. The product will at that point visit every url and gather email tends to that it has found alongside the title of the page and the URL and spare the entirety of the data to an information base. CBT Mass Email Sender Desktop Software

    ReplyDelete
  19. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... free email extractor csv file

    ReplyDelete
  20. I appreciate this article for the well-researched content and excellent wording. I got so interested in this material that I couldn’t stop reading. Your blog is really impressive. how to send bulk mail

    ReplyDelete
  21. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. ClickFunnels Vs Kartra

    ReplyDelete
  22. Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. new company names

    ReplyDelete
  23. Really appreciate this post. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it! Parallel profits bonus

    ReplyDelete
  24. I can recommend primarily decent and even responsible tips, as a result view it: Search Engine Scraper

    ReplyDelete
  25. An invite email is an extraordinary method for presenting both cold and warm prompts your administrations. Your client might have selected in at an open house or your site, or they might be somebody you've overcome a reference. gmx mail

    ReplyDelete
  26. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. Chen Zhi Cambodia

    ReplyDelete
  27. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. https://sites.google.com/view/economicahead/providing-donations-to-500-needy-families

    ReplyDelete
  28. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. cambodia chenzhi

    ReplyDelete
  29. If you set out to make me think today; mission accomplished! I really like your writing style and how you express your ideas. Thank you. https://eatatbillybombers.wixsite.com/business-charity/post/cambodian-skills-development-to-help-lower-unemployment

    ReplyDelete
  30. Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. cambodia chen zhi

    ReplyDelete
  31. The Salesforce Sharing-and-Visibility-Architect Exam Objectives from a reliable way will make your good results in Salesforce Sharing-and-Visibility-Architect certification test questions pretty much effortless

    ReplyDelete