0

I am trying to replicate SalesForce's email-to-case logic within the application layer. However the third way SalesForce matches emails to cases doesn't seem possible. It's meant to use ClientThreadIdentifier of the EmailMessage object, which doesn't seem to exist.

This is from their documentation:

If Email-to-Case can’t find any emails with a matching In-Reply-To or References header, it checks the incoming email for an Outlook-specific header called Thread-Index. The first 22 bytes of this header uniquely identify the thread. If Email-to-Case detects a Thread-Index header on the incoming mail, it looks for matching information in the ClientThreadIdentifier field in EmailMessage records. If a match is found, the customer’s reply email is linked to the related case.

As per the title, how can this logic be replicated if SalesForce is saying its own column (as documented) doesn't exist?

6
  • Have you enabled the new Email-to-Case threading behavior Release Update?
    – cropredy
    Nov 2, 2022 at 23:48
  • Hi yes that was enabled. But I want to replicate the logic in the application-layer which makes API calls to SalesForce (because SalesForce says email-to-case isn't available via external Apex calls). Nov 3, 2022 at 9:01
  • Are you saying that all interactions between sfdc and the "customer" are via rest api? No actual emails? If so, then why not use the caseId or caseNumber in the rest payloads?
    – cropredy
    Nov 3, 2022 at 14:56
  • No, we've got emails coming in (not to SalesForce), into our system. We need to determine if they belong to an existing case, in which case we'll attach it, or not in which case we'll process it our side. Nov 4, 2022 at 15:05
  • why not ensure the CaseNumber is in the subject line of all outbound emails and then use that in your inbound REST processing to find the case, if any.
    – cropredy
    Nov 4, 2022 at 17:22

1 Answer 1

0

I had this same issue initially and I solved this by making sure the Apex code I was writing was version 56.0. The code had already existed and I was only updating it to meet the new standard. However, I left the code at version 54.0 initially and I noticed an issue with the SOQL query. This might be the issue.

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailmessage.htm

From the docs:

A value used by third-party email clients to identify which thread an email belongs to, stored only when found in email headers. To identify an email thread, Email-to-Case can use this field if it’s in a format that's specific to a third-party email client. For example, if Email-to-Case detects an Outlook-specific header called Thread-Index, it stores its first 22 bytes in uppercase hexadecimal format in this field. Available in API versions 56.0 and later.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .