Update the Case Status Through Email-to-Case Response

Update the Case Status Through Email-to-Case Response

Last Updated on June 10, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How can you automatically update the case status when receives a response from customers via Email-to-Case?


This blog post will help us to understand the following

  • Understand how email-to-case works 
  • Create a flow that fires on the customer’s response to an email-to-case 
  • Use decision element to validate the data
  • Use the update records element to open a closed case

Business Use Case

Pamela Kline is working as a System administrator at Universal Containers (UC). She has just implemented an email-to-case process. Now she has received the following enhancements from the support agent:

  1. Automatically add customer response to the case email thread, when the customer replies to the email that has been sent from a case.
  2. Re-open a case when the customer responds to a support agent email, within five days of case closure.

Automation Champion Approach (I-do):

Email-to-Case allows you to create a case automatically when a customer emails in. It also populates some key information, for example, the email subject becomes the case subject, and the email body-mapped to the description. You can configure multiple Email-to-Case channels based on your business use case.

Next, you have to understand the Thread ID. The thread ID is a unique ID generated for outbound emails within the case. The thread ID will look like ref:_00D90wAtk._500901Kc5WN:re. To automatically add customer responses to the case email thread,  make sure that Email-to-Case has been configured correctly for customer email responses to be attached to the case.

  • Email Threading is an important part of the Email-to-Case setup. Setting this up essentially means that, if a customer emails you more information about an existing Case, their second email will be attached to their existing Case instead of creating a new Case. If you want to auto add a unique Thread ID into your auto-responses and other outgoing emails, then navigate to Setup | Feature Settings | Service | Email-to-Case and select the check-boxes as shown in the following screenshot

Insert Thread ID in the Email Subject and Body

  • When you are replying to a customer make sure to change the address from the Owner to the Email to the Case support address.  If this is not changed, then the response from the customer will be sent to the owner of the case and will not be added to the Email Thread. Follow the below steps to add Email-to-Case support address to from address (Basically we are going to add Email-to-Case support address to Organization-Wide Addresses:
  1. Copy the Email Services Address (i.e. Long email address) from Email-to-Case as shown in the preceding screenshot.
  2. The next step is to add a new Organization-Wide Email Addresses. Use Email Services Address (Long address) in place of  Email Address, as shown in the following screenshot:Organization-Wide Email Addresses
  3. For verification purposes, Salesforce will send an email notification with a confirmation link to the above-mentioned email address
  4. As we are using an Email-to-Case routing address, it will automatically create a case in your org, from where you can verify the ownership of the email address.Verify your Salesforce Organization-Wide Address
  5. Click on the link mentioned under the description to verify the Organization-Wide Address. After successful verification, you can use the Email-to-Case Support address to send out an email from Salesforce.

Email to Case support address

Sample Output

Email Thread

Solution for Use Case – 2

Our next task is to create a Flow on the Email Message to execute, only when an email message is received and re-open a case when the customer responds to a support agent email, within five days of case closure.

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Let’s take a pause here, familiarize yourself with the EmailMessage objects in Salesforce. 

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it. Let’s begin building this automation process.

Guided Practice (We-do):

There are 4 steps to solve Pamela’s business requirement using Record-Triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Formula to calculate the number of days between the close date and today 
  3. Add a decision element to check the case status and number of days formula 
  4. Add an update records element to re-open a case

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: EmailMessage
    2. Trigger the Flow When: A record is created
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 2: Formula to Calculate the Number of Days Between Close Date and Today

  1. Under Toolbox, select Manager, then click New Resource to calculate the number of days between case close date and today. 
  2. Input the following information:
    1. Resource Type: Formula
    2. API Name: forN_DaysSinceCaseClosed
    3. Data Type: Number
    4. Decimal Places: 0
    5. Formula: {!$Flow.CurrentDate} – DATEVALUE({!$Record.Parent.ClosedDate})
  3. Click Done.

Step 3: Using Decision Element to Check Case Status and Number of Days Formula

Now we will use the Decision element to check the case status and the number of days formula. 

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!$Record.Parent.Status}
      2. Operator: Equals
      3. Value: Closed
    2. Add Condition
    3. Row 2
      1. Resource: {!$Record.Incoming}
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
    4. Add Condition
    5. Row 3
      1. Resource: {!forN_DaysSinceCaseClosed}
      2. Operator: Less Than or Equal
      3. Value: 5
  5. Click Done.

Step 4: Add Action – Update Records

The next step is to update the case status to re-open. We will use the Update Records element. 

  1. On Flow Designer, below the Recently Closed Cases node, click on the +icon and select the Update Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Click Specify conditions to identify records, and set fields individually
  4. Object: Case
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Equals
      3. Value: {!$Record.ParentId}
  7. Set Field Values for the Case Records
    1. Row 1:
      1. Field: Status
      2. Value: Working
  8. Click Done.

In the end, Pamela’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 54
  5. Interview Label: Reopen Closed Case {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.  

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

31 thoughts on “Update the Case Status Through Email-to-Case Response

  1. Thank you for saving me 45 minutes trying to figure this out. I was able to get this working quickly. Thanks for the clear wording and instructions, the Trailhead writers could learn a thing or two from you~

  2. I didn’t have any expectations concerning that title, but the more I was astonished. The author did a great job. I spent a few minutes reading and checking the facts. Everything is very clear and understandable. I like posts that fill in your knowledge gaps. This one is of the sort.

  3. Hi Rakesh,
    First, thank you for this solution.
    When I debug, it is working as expected as per log. But when emailed to test, the case status is not updated from closed to open.

  4. Thanks for this great post. But i’m facing the following issue. Out requirements are little bit different but also ends with an update on the case. When the customer replies to an email the Case status is waiting on reply. The flow should update the case status to In progress. This happens, but a few seconds later Salesforce overwrites this status with New Email… How can we prevent that from happening?

  5. I didn’t see Nige’s answer to the flow not accepting the formula but solved it as follows.

    I created two new formula resources of type Date
    and stored the two dates.
    The formula then became
    {!forCurrentDate} – {!forClosedDate}
    which worked.

    And I couldn’t debug it as I couldn’t select an email to test it on.
    So I used an email alert while debugging.

  6. For anyone getting the same error as Debra S. just remove the – symbol from the forumla and replace it with the subtract symbol on your keyboard or via the operator menu in the formula and the syntax passes 😀

  7. What would be the solution to reopen closed case on a new email in the world where the Case Thread ID has been deprecated? The use case I have is, case is closed, an automation sends an email informing the case requestor the case is closed. If the customer replies to that email, there is neither Thread ID nor Header information that will associate the new reply on a case to the original one. Is there a workaround without using custom code? Thank you.

  8. Hi Rakesh,
    I’m getting a syntax error with the formula, {!$Flow.CurrentDate} – DATEVALUE({!$Record.Parent.ClosedDate}), stating the formula expression is invalid. Where might I have gone wrong? My formula looks just like your image.

  9. what if it is after the 5 days and you do not want to open the existing case. Are you just ignoring the communication from the client? I think there needs to be followup and create a new case (clone the existing?). How do you get this reply to be associated to the newly created case.

  10. Thanks so much for this. I did not even realize there was an object called email message. I was able to implement this base flow with tweaks to address a pain point within a company’s process. Thanks again.

  11. Any suggestions so that when users originally CC’d on a case reply to a case a new Case does not get created? There does not seem to be a way to setup auto-response to also go to users that are CC’d so that they also get the thread id in the reply.

    1. Actually – I guess I now see the “Case Auto-Response Rules” settings. (I only find answers to problems right after posting.. even if after searching for long periods. ha) Will test to confirm…

  12. I am trying to follow the process builder steps but I don’t have [EmailMessage].Parent.Status and I need to indicate in the criteria that the case has to be closed to start the process. Is there another way to proceed?
    Thank you, the article is very clear and easy to follow 🙂

  13. This is a great use case! Is there a way to test this out in a Sandbox I wonder? I don’t know of a way to turn on temporary email delivery within the sandbox. Any suggestions would be appreciated.

    *Bailey Rudd * Sales Operations | CRM Administrator

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.