How to Get the Lightning Threading Token of a Record

How to Get the Lightning Threading Token of a Record

Salesforce uses email threading to automatically link incoming and outgoing emails to a related Case record. This keeps the entire conversation between the customer and the support team organized in one place. In the Spring '23 release, Salesforce introduced a new email threading approach called Lightning Threading. With this update, emails are matched using a secure token, replacing the previous method of using RefID strings.

When you are sending an email via Send Email action in Flow, you can now add a threading token to the email body or subject.

Add Lightning Threading Token

Although adding a Lightning Threading Token is a useful feature, it has some drawbacks. For example, the token is always added at the end of the subject or body, and you cannot control its placement. Additionally, it’s not possible to modify its style (such as font size or color). Furthermore, it doesn't follow a specific format. Therefore, you cannot use a formula field to generate it by yourself (unlike the RefID). As a result, it may seem like these toggles are the only way to include the threading token in the email. However, you can also use Apex to get the Lightning Threading Token of a record.

In this post, you can find a flow action that gets the Lightning Threading Token of a given record.

How to Use the Component

1- Install the component using the installation links below.

2- Add a new action to your flow and search for Get Threading Token. This is the name of the action that you installed.

Get Threading Token Action

3- Provide the Id of the record as an input.

Configuration of the Get Threading Token Action

Output of this action is the Lightning Threading Token of the record.

Example

Here is a record-triggered flow that sends an email when a new Case record is created. It first uses the Get Threading Token action to retrieve the token for the record. Then, it sends an email to the customer, including the Lightning Threading Token in the email body.

Flow to Send an Email

As you can see, the token is smaller than the rest of the text and appears in red.

Email Body
Email Body

Note that the "Add Threading Token to Body" and "Add Threading Token to Subject" parameters are set to false. This is because we are manually adding the token to the email body and do not need the flow to do it automatically.

Send Email Action

Moreover, since the Lightning Threading Token of a record will never change, you can save it to a field on the object.

Installation Links

Use this link to install in production or developer edition environments.

Use this link to install in sandbox environments.

Release Update: Disable Ref ID and Transition to New Email Threading Behavior

In order to use the Lightning threading, you should turn on "Disable Ref ID and Transition to New Email Threading Behavior" release update. This update turns off RefID threading and transitions to Lightning threading in Email-to-Case.

Although Salesforce previously announced the update would be enforced in Spring '25, they no longer plan to enforce the release update. However, it is strongly recommended to enable the update and migrate to Lightning Threading, as it's more secure at threading emails to cases than RefID.

1 Trackback / Pingback

  1. Different Ways of Sending Emails from Flow - Salesforce Time

Leave a Reply

Your email address will not be published.


*