1

We're looking for ways to get rid of some data in several orgs. One potential target would be the Task records that get created along with every EmailMessage. (I.e. the Tasks of which the Id is stored in the ActivityId field on the EmailMessage records)

What would happen when we delete those Task records? For the few that I tried, I did not seem to see any difference in Salesforce. Do these Task records actually serve a purpose?

2 Answers 2

5

Note: Some of the following is conclusions my team reached for which we could not find explicit documentation; Salesforce support eventually confirmed our findings, just this past week.

The EmailMessage object does not have any explicit CRUD or Sharing Settings. There is also no EmailMessage__Share object, so Apex sharing is off the table. With no explicit CRUD, you cannot assign "View All" at the object level.

With no explicit sharing options, Salesforce defaults to 'Controlled by Parent'. EmailMessage has a ParentId field, which is a lookup to Case (I believe because the EmailMessage object was originally added to support Email-to-Case). If this field is present the case is the parent and sharing is controlled by the case. Otherwise, ActivityId is used, and the auto-generated Task becomes the parent. Task sharing is a bit complicated as it can use WhoId or WhatId, and a Contact as the WhoId would then depend on the contact's Account lookup.

The result is that even if you build a custom Activity Feed to replace the Activity related list, only the EmailMessage's owner would be able to see it without the Task. We had originally added a trigger on EmailMessage to remove these tasks, which we eventually removed for this reason.

0
0

For what it's worth: I found that the Task record is necessary to have the EmailMessage appear in the Activity Related list on the Contact record and other Related records. So if we delete the Task record, the EmailMessage will disappear from the Contact's Activity history.

Only exception: the email will still remain visible in the Case Feed, so there's a special mechanism built in there, probably based on the ParentId of the EmailMessage.

You must log in to answer this question.

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