Using Workflow to Update a Case When an Email-to-Case Message is Received

December 1, 2008 Appirio

Andrea Giometti

We are going back to basics here, but recently we were looking to implement what seemed to be basic functionality and found ourselves jumping to complex solutions while overlooking the native functionality within Salesforce.  With the development tools now available in Salesforce such as Visualforce and Apex Code, customizations are seemingly limitless.  However, why reinvent the wheel if a solution already exists within Salesforce’s standard functionality? 

The issue was that we needed to update the status of a case in Salesforce when an inbound email was received for an existing case via email-to-case.  It turns out that since the Spring ’08 release, you can do this with standard email-to-case workflow.  When you enable email-to-case in your org, an object called Email Message is enabled for workflow rules. In that object is a field called ‘Is Incoming’ which is set to true for any inbound emails.  The key to the workflow is that you don’t apply it to the Case object, you apply it to the Email Message object.  This will allow you to then do a field update on the Case object.  Similarly, you can use workflow rules when a case comment is received by applying the workflow rule to the Case Comment object.  This can be particularly helpful if you are using a Customer Portal and want to update a field on the Case object when a customer adds a comment to a case.

By implementing a simple workflow rule, we were able to add functionality that would automatically re-open a case if an email associated with a closed case is sent by the customer.   Others uses for this workflow rule could be to re-assign a case, say to a queue, when an email is received and the case meets certain criteria.  In addition to checking the Is Incoming field, you could also create a workflow rule that checks the status of the email message and makes changes to a case field based on that status.  Basically, once you discover the Email Message object is available in workflow, the possibilities are endless.

To create the workflow rule that updates a case field on an inbound email:

  1. Go to Setup | App Setup | Create | Workflow & Approvals | Workflow Rules and click New Rule.  
  2. Select Email Message as the Object the workflow rule applies to and click Next (note that Email Message will only be available if email-to-case has been enabled in the org). 
  3. Enter a name for the workflow rule and select when it should be evaluated.
  4. Enter the following criteria to enable the workflow rule to fire when an email is inbound:
    • ‘Email Message: Is Incoming’ equals ‘True’
  5. Add additional criteria if you only want the workflow rule evaluated under certain circumstances such as Case: Closed equals True, or Case: Status does not contain Closed.
  6. Click Save & Next
  7. Click Add Workflow Action and select New Field Update
  8. Enter a name for the Field Update and then select the case field to update.

Previous Article

I was exploring Twitter’s use of the TinyURL utility and couldn’t find any more information on their API fr...

Next Article
Learning Apex: Display Multi-Object Data in Tables Easily with Apex Dummy Classes

Will Supinski Creating tables in Visualforce is easy. Provide a list of Objects to display and define vario...