Monday, November 28, 2022

Salesforce: Email-to-Case and EmailMessage object

Two years back, we shared about the EmailMessage object here, this blog will share the relationship between how the email is stored in the EmailMessage with email-to-case.

This blog is written for email header-based threading, not the older string-based threading, check out the difference here.

Email Header

Outlook Email Properties

There are 3 main pieces of information from the email header that determine email header-based threading.
  1. Message-ID: this is a unique Id from each email sent.
  2. In-Reply-To: when someone reply, reply all, or forward email, this will be the Message-ID of the email replied or forwarded -- this will be not available for a brand new email
  3. References: this will contain ALL Message-ID in the past related to the email, because of the the email is replied or forwarded -- this will be not available for a brand new email
Email header example in Outlook:

Another sample from Gmail:
<> <>


ThreadIdentifier is a field in the EmailMessage object that will be auto-populated when sending emails or receiving emails to Salesforce, including manually logged emails.

For email-to-case, ThreadIdentifier is the Message-ID of the 1st email sent by a user as a brand new email (not reply/forward), and that email possibility not be sent to the email-to-case email address alias yet.

- A send email to B [Message-ID = A123]
- B replies A, and also cc to email-to-case email address [Message-ID = B888]
ThreadIdentifier in this scenario is A123, even though A did not send the email to the email-to-case email address. 

Email-to-Case Threading

As per this article, there are 2 main points that determine if an email sent to email-to-case alias will create a new case or be attached to an existing case:

  1. Looks for "MessageIdentifier" in the Salesforce EmailMessage object to match with the "In-Reply-To" email address in the email header, if not found, continue to (2) 
  2. Looks for "MessageIdentifier" in the Salesforce EmailMessage object to match with the "Reference" email address in the email header 

If found, link that email to the case by looking at ParentId (which is Case Id) from the matching record of the EmailMessage object. So, the matching here is not based on ThreadIdentifier. 

First scenario:
1. A create a brand new email and send it to B and C
2. B reply all and forward the email to
3. C reply all and forward the email to

The above scenario will create 2 cases:

  • with the same ThreadIdentifier, but MessageIdentifier generated from email B (2) and email C (3) is different
  • all references in the following emails will not contain the original email A (1) in their reference, so these 2 cases will be continuously run independently.

Second scenario:
1. A creates a brand new email, sends it to B, also to and 
2. B reply all

What will happen from the above scenario:

  • The first email from A will generate 2 cases with the same MessageIdentifier
  • When B hit reply all, there are 2 streams of email reaching Salesforce, and both looking for the same MessageIdentifier, the system will simply attach the email to any of these 2 cases, but from my trail, these 2 streams' of email are attached to the last cases created. so there will be 3 emails in the last case created

Third scenario:
1. A creates a brand new email and sends it to B, also to  
2. B reply all and add

What will happen from the above scenario:

  • The first email from A will generate 1 new case
  • When B hit reply all and adds new email alias linked to email-to-case, the "In-Reply-To:" in the second email will point to the Message-ID of the first email which is the MessageIdentifier for the case created in the first email, so there will be no new case created here

Sample querySelect ParentId, CreatedDate, Status, Subject, FromAddress, ToAddress, CcAddress, MessageIdentifier, ThreadIdentifier, Id, ReplyToEmailMessageId from EmailMessage where CreatedDate = Today


Saturday, November 26, 2022

Salesforce: Send List Email (3)

his is to continue Salesforce: Send List Email and Salesforce: Send List Email (2) written months ago. 

You can send mass email to a maximum of 5,000 external email addresses per day per licensed Salesforce org based on Greenwich Mean Time (GMT), and sending email from list view is considered as mass email. For example, if you have in your email 10 times that counts as 10 against the limit.

You can send mass emails only to contacts, person accounts, leads, and your internal users. 

You can send an unlimited amount of emails through the Salesforce UI to your internal users, which include portal users.

To mass email from the list view:

  1. Select/create the list view
  2. Select the contacts/leads checkbox
  3. Click the "Send List Email" button, if you do not see the button, make sure the button is added to the list view and you have "Allow sending of List Emails" permission, see this blog for detail.

In the Send List Email window

  • You will see the balance of send email limit remaining
  • You can select "From" based on your setup, including Organization-Wide Email Addresses
  • You can use an email template, merge fields, and attach files
  • You can Send Later and Save as Draft
  • Each recipient will only see their name as the recipient, not the whole recipient's name

Tips: to see your draft email, looks for "List Email" from the 9-dots icon


Wednesday, October 26, 2022

Salesforce: Field Dependency across Record Type

This is to continue the previous blog Record Type on Creation, the scenario here: for the same user, the list of values for a picklist field configured as a dependent field should be different across record types.


1. Set the field as a dependent field

2. Include ALL values of the dependent field in the controlling field, not only for a specific record type

3. Configure the field values available for each record type

4. Done

Now, you should see different available values for each record type for the same field.

Same user, same field, different record type, and different list of values.

Salesforce: Record Type on Creation

Background: a user does not see the Record Type prompt when creating a new record.

This is probably caused by:

1. The user profile is not enabled for certain record types of an object

To check this, go to the user profile, not to the object.

Looks for Record Type Settings

If you have Enhanced Profile User Interface enabled, look for Objects Settings, then Record Types and Page Layout Assignments

Additionally, you also can enable record type for certain users with permission set, see this blog.

Note: even if a user can't create a record with a specific record type, because it is not enabled, the user will be still able to access the record, as that is controlled by record visibility.

This scenario (no record type prompt) only happened when there is only 1 record type enabled for the user.

2. The user sets Default Record Type

Go to User Setting, and looks for Set Default Record Type under Display & Layout.

Note: this is not Advanced User Details and is not configurable by the admin, so the admin needs to log in as the user to check.


Friday, October 21, 2022

Salesforce Lightning URL Hack

Scenario: Universal Inc would like to increase staff productivity with fewer clicks when creating a Case from the Account page, users still need to enter other fields, but a few fields have been populated by default:

  • Skip record type prompt
  • Type = Other

Solution: create a custom button and add it to the page layout. Here is the URL:



Salesforce Inbox Included

More than a year ago, we wrote about Salesforce Inbox, and things have changed since the blog was written, mainly on the license, permissions set, and permissions. Here is the update:

In Summer '22 release, it was announced that Sales Cloud Unlimited and Performance Editions Now Include Inbox Without an Add-On License. If you are not using Unlimited and Performance Editions, you can still buy additional Inbox licenses separately (which also include the full Einstein Activity Capture license), check this

The new standard permission set is called Inbox Included, which contains Use Inbox permission, or as admin, you can create a custom permission set and select license = Inbox.

Or, you also can use the standard permission set Sales Cloud Included Bundle, which includes all permissions for Sales Cloud Unlimited. If you also purchased Sales Cloud Einstein and use the Sales Cloud Einstein permission set, Use Inbox permission is included in that permission set, so no need to assign many duplicates and unnecessary permission sets, always look for simplicity and clarity.

So again, what is Inbox? It is a productivity tool to work with Salesforce from your email client.

  • Contextual CRM — see relevant CRM records in your email client.
    • Easily create Lead/Contact if the sender or recipients are not in Salesforce.
  • Create — allow users to create new records based on Global Actions configured in Lightning.
  • Search — stay in Outlook/Gmail to search and access Salesforce records.
    • Include: view detail and related tab, edit records, log email, open in Salesforce, and perform Chatter actions.
  • Managed Task — create and manage Salesforce’s Tasks from Outlook.
  • Log Emails — including incoming and outgoing emails.
  • Insert Availability — let your recipient select a time slot for a meeting based on your calendar.
  • Email Templates & Text Shortcuts — reuse and standardize email templates for teams and personalize text shortcuts.
  • Track Outgoing Emails and Links — get insight when the recipient read and clicks links in the email sent.
  • Send Later — ensure that people receive your email when they are most likely to act upon it, this is also available when sending email from
  • Mobile apps — manage customer communications to include Salesforce CRM records from mobile.


Page-level ad