**Stop using RefId, Start using thread token. ** Starting Spring '23, Salesforce introduced Lightning threading for Email-to-Case, replacing Ref ID with a secure token for email matching. This update, enforced in Spring '25, aims to improve reliability and security in email threading by using token- and header-based matching. To handle the transition from Ref ID to Lightning threading in Salesforce, update email templates to include the Case Thread Token merge field, adjust custom code to support token- and header-based threading, and test changes in a sandbox. Enable the "Disable Ref ID and Transition to New Email Threading Behavior" release update in Setup. https://help.salesforce.com/s/articleView?id=000389648&type=1
In the standard reply action, the system provides you with the thread token for the email. However, this is not the case when you manually send the email in the flow using the SendEmail action. So where is it? You should use the EmailMessages.getFormattedThreadingToken method in Apex to generate a secure token. This token is then included in the subject or body of outbound emails. When a reply is received, Salesforce matches this token to the correct case record, ensuring emails are correctly threaded without using Ref IDs. This method requires Lightning threading to be enabled and only supports Case record IDs. https://developer.salesforce.com/docs/atlas.en-us.244.0.apexref.meta/apexref/apex_System_EmailMessages_getFormattedThreadingToken.htm?_ga=2.15341374.969295726.1707191828-950895856.1667797139