Skip to main content

Hello Salesforce Team,

I have a question regarding the EmailMessage object relationships.

How can we reliably determine if an EmailMessage is linked to a Case?

I noticed there are two fields:

  • RelatedToId (“Related To”)
  • ParentId (“Parent Case”)

I would like to understand the expected behavior between these two fields:

  1. Can RelatedToId be populated while ParentId is empty?
  2. Can ParentId be populated while RelatedToId is empty?
  3. When an EmailMessage is linked to a Case, should both fields always contain the same Case Id?
  4. Are there standard scenarios where the values differ?

From the documentation, I saw the note:  “RelatedToId and ParentId should have the same value when ParentId is set. You might see unexpected results otherwise.”

Could you clarify the standard Salesforce behavior and best practice to identify whether an email is associated with a Case?

Thank you.   

 

@* Service Cloud * 

1 answer
  1. May 28, 2:08 PM

    The fun of EmailMessages... 

     

    EmailMessage.ParentId in a link to Case only.  

    EmailMessage.RelatedToId is only added when Enhanced Email is activated.  

    When EmailMessage.ParentId is Case, EmailMessage.RelatedToId is also case.  

     

    EmailMessage.RelatedToId provides a What Id relationship (for example Account, Opportunity). However, it is not the only relationship to other objects (especially Who Ids). For that, you need to look at EmailMessageRelate. This object provides all the relationships. 

     

    Rule of thumb. If you are specifically looking for Email Messages related to Cases, stick to the ParentId field.

0/9000