function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NerijusNerijus 

EmailMessageRelation contact id

Hi all,

I use the Salesforce for Gmail integration to log the emails in Salesforce.
When EmailMessage object is created I query an EmailMessageRelation object to find all the contacts that are related with this email.
On the UI I can see the contact is related as "Other Related People" and has a type of contact.
But when I query EmailMessageRelation it doesn't provide me RelationId nor RelationObjectType, all I get is Id, EmailMessageId, RelationAddress and RelationType. Non of them indicating who the contact is.

Any ideas why can't I get the contact id?

I have another old EmailMessage which has multiple contacts related with it, and EmailMessageRelation returns RelationId (contactId) and RelationObjectType (contact), but I can't seem to replicate that.

Thank you for your responses!

Nerijus
 

Prateek Prasoon 25Prateek Prasoon 25
It's possible that the email you are currently querying for only has one contact related to it, and that contact is the "Other Related Person". In this case, the relation type for that contact will be "Other" instead of "Contact", which is why you are not seeing a contact Id or relation object type.

To confirm this, you can try creating an email in your Gmail with multiple recipients, including at least one contact that is related to a Salesforce record. Then, check the EmailMessageRelation records for that email in Salesforce to see if you are able to retrieve the contact Id and relation object type.
If you are still not able to retrieve the contact Id and relation object type for the email, it's possible that there is a data issue or a bug with the Salesforce for Gmail integration. In this case, you can reach out to Salesforce support for assistance.


If you find my answer helpful, please mark it as the best answer. Thanks!