---
schema_version: "1"
id: 40e5cfd5b55a121707ed1edaf405d16656dc25c488f8534067cb52594658c7b9
title: Update to Lightning Threading for Email-to-Case
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/customizesupport_email_thread_update.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.customizesupport_email_thread_update.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 85534004e8e60e43a15284cb993c3b22c77438162cdf78f69f50f71eba16af9f
description: Lightning threading is a secure method used by Email-to-Case to associate emails with related cases. To switch to Lightning threading from Ref ID threading, you’ll enable a release update, update your Email-to-Case settings, and update any email templates and custom code that rely on older threading methods.
products:
  - Service Cloud
  - Digital Engagement
release: "264"
---
# Update to Lightning Threading for Email-to-Case

Lightning threading is a secure method used by Email-to-Case to associate emails with related cases. To switch to Lightning threading from Ref ID threading, you’ll enable a release update, update your Email-to-Case settings, and update any email templates and custom code that rely on older threading methods.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col style="width:100%"></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=service.customizesupport_email_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the Salesforce editions and user interfaces that support Email-to-Case.">View supported editions</a>.</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col>
          <col>
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d122790e61">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">To view release updates: </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">View Setup and Configuration</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">To enable or disable release updates: </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">Manage Release Updates OR Customize Application</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">To enable and set up Email-to-Case: </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">Customize Application</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">To edit public email templates:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">Modify All Data, Manage Public Lightning Email Templates permission, or template
              ownership</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">To define, edit, and delete Apex classes:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d122790e61 ">Author Apex</td>

          </tr>
        </tbody>
      </table>

We recommend first following these steps in your sandbox, and then repeating them in production.

If you like learning via audio, this podcast-style audio tour explains how email threading works in Salesforce and how to upgrade to Lightning threading: [Audio Tour: Email-to-Case Threading](https://salesforce.vidyard.com/watch/aBju1pKBb112SRJAkHTEaY). The audio features an AI-generated conversation between two Salesforce admins.

## Step 1: Enable the Release Update

First, make the official change to switch to Lightning threading. When taking this step in production, do so outside of business hours to minimize disruption to users and test the change in your sandbox first.

1. In Setup, enter Release Updates in the Quick Find box, and then select **Release Updates**.
2. On the update named Disable Ref ID and Switch to Lightning Threading, click **Get Started** and install the release update.
    
    If you don’t see this release update, you’re not using Ref ID threading and can skip to Step 2.

## Step 2: Update Your Email-to-Case Settings

Turn on key settings in Setup related to threading.

1. From Setup, enter Email-to-Case in the Quick Find box, and then select **Email-to-Case**.
2. Verify that these settings are selected:
    1. **Use email headers for threading**: Turns on the header-based component of Lightning threading.
    2. **Insert email threading token in email subject**, **Insert email threading token in email body**, or both: Turns on the token-based component of Lightning threading.
3. Save your changes.

## Step 3: Update Your Email Templates

To ensure that incoming emails are associated with the right case, check your email templates for the Case Thread ID merge field. This merge field relies on the Ref ID threading method and doesn’t work with Lightning threading.

1. From the App Launcher, go to the **Email Templates** tab.
2. Search the body and subject of each email template for the {{{Case.Thread\_Id}}} merge field.
3. If you find the merge field, remove it. Here’s an example of a template that contains it.
    
    ![Email template with Case Thread ID merge field shown in email body](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/support_channels/images/email/email_merge_field_remove.png)

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_channels-264-0-0-production-enus/f3c4b3d2-ff86-4f7c-9fe2-3d8b23d35109/images/icon_note.png)

Note

If you chose not to select the settings in Step 2: Update Your Email-to-Case Settings, you can replace the {{{Case.Thread\_Id}}} merge field in your templates with the {{{Case.Thread\_Token}}} merge field. Using merge fields to add threading tokens to emails is a manual alternative to the Lightning threading settings in Setup.

## Step 4: Update Your Custom Code

If you have custom code that depends on the Ref ID threading behavior, update it to add support for Lightning threading.

1. From Setup, enter Apex Classes in the Quick Find box, and then select **Apex Classes**.
2. Click **Compile all classes**. If any Apex classes fail as a result of the update, the failures appear.
3. Update any failed Apex classes to remove references to Ref ID threading.
    1. Remove references to the deprecated Apex method getCaseIdFromEmailThreadId.
    2. For incoming emails, include the [EmailMessages.getRecordIdFromEmail](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_EmailMessages_getRecordIdFromEmail.htm) or [Cases.getCaseIdFromEmailHeaders](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_Cases_getCaseIdFromEmailHeaders.htm) methods to retrieve the Case ID from email tokens or email headers, respectively. The method documentation includes code samples.
    3. For outgoing emails, use the [EmailMessages.getFormattedThreadingToken](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_EmailMessages_getFormattedThreadingToken.htm) or [Cases.generateThreadingMessageId](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_Cases_generateThreadingMessageId.htm) methods to include a threading token or email header-based threading information, respectively, in outgoing emails. Email-to-Case can then thread replies to the right cases.

After the release update is enabled, incoming emails are matched to cases using tokens rather than Ref IDs in the email subject or body. If no matching case is found, email header-based threading is used. Outgoing emails no longer contain a Ref ID, and emails continue to thread to existing cases using header-based threading, providing a smooth transition.