Loading

Error 'Insufficient Access' and considerations for delete of EmailMessage records

게시 일자: Apr 18, 2023
상세 설명

Salesforce organizations that have Set Up Enhanced Email may notice high storage usage for both Tasks and EmailMessage upon 'Viewing Storage Usage' as outlined in the Monitor Data and Storage Resources documentation.

An administrator may desire to delete records to free up available storage space however, they may encounter an 'Insufficient Access Rights' message when attempting to delete EmailMessage records.

Please review the following behaviors when planning to delete EmailMessage and their associated Tasks records for orgs with enhanced email enabled.​

 
솔루션


EmailMessage record delete behaviors:

 
  • Deleting an email message automatically deletes the associated Task, but deleting a Task doesn’t delete the associated Email Message. See Considerations for Using Enhanced Email for more details.

Note: If your organization has Set Up Email-to-Case, deleting an email message that's related to a Case record will not automatically delete the associated Task.
 
  • Deleting EmailMessage records before their related Tasks is recommended best practice as the Task records are deleted without the need to contact Support.  
  • Deleting an EmailMessage's related Task may result in EmailMessage records persisting in an orphaned state.  
  • Administrators with 'Modify All Data' may delete EmailMessage records as long as they're not in an orphaned state.
 
Note: If an EmailMessage record has entered an orphaned state (where it has no related Task (ActivityId) or Case (ParentId) records) it's expected and by design for only the creator of the orphaned EmailMessage to have permissions to delete it.

Administrator Users with 'Modify All Data' may not be able to see the option to delete orphaned EmailMessage records that have been created by other Users in the user interface and deleting via the API may result in an error:

 
'Insufficient Access Rights On Object Id: INSUFFICIENT_ACCESS_OR_READONLY'
 
  • Since it may not be scalable to ask orphaned EmailMessage record owners to delete their own orphaned EmailMessage records (where ActivityId=NULL and ParentId=NULL) they may be removed in mass by contacting Salesforce Support.
  • Deleting related Contact or Lead records contained in the Name (WhoId) field on the EmailMessage's related Task record will not cascade or automatically delete the EmailMessage record.  
  • Deleting related Case records will cascade or automatically delete any related EmailMessage records and their related Task records.
 
For example, if an EmailMessage record has a Case populated in its 'Parent Case' field, when that related case is deleted the EmailMessage and its associated Activity or Task record is also deleted.
 

Delete Contacts or Leads and then associated EmailMessage and Task records


Always back up your data before performing any Data manipulation by either Exporting Backup Data or through Export Data and selecting all fields on the appropriate object via the Data Loader. See Insert, Update, or Delete Data Using Data Loader for more details on how to perform a delete operation.
 
  1. Identify which Contact or Lead records to delete. Create .csv file with Contact or Lead record Ids.
  2. With Data Loader, delete Contact or Lead records with the .csv file from step 1.
  3. Export any resulting orphaned Tasks (WhoId = NULL AND WhatId = NULL) to keep as a backup and create CSV file with orphan Task record Ids.
Example of Data Loader query: (Select Id, WhoId, WhatId, Subject, Status FROM Task WHERE WhoId = '' AND WhatId = '')
 
  1. If working with a small subset of orphan Task records you may elect to build a query using Task Ids returned from the previous step. This will return orphaned Task's related EmailMessage records to keep as a backup and create a CSV of EmailMessage record Ids.

Example of data loader query: (SELECT Id FROM EmailMessage WHERE ActivityId IN ('<TaskId1>','<TaskId2>',<TaskId3>'))

Add any additional fields you would like to include for backup and replace/add orphaned Task record Ids from step 3 in place of the <TaskId1> <TaskId2> <TaskId3> values in the conditional query above.
 
Note:  If there are to many orphaned Task Ids to build the query to return EmailMessage record Ids for delete skip to step 6.
 
  1. With Data Loader, delete orphaned EmailMessage records with the CSV from step 4. This will also cascade or automatically delete their related orphaned Task records as well.
  2. With Data Loader, delete Tasks with CSV file from step 3.
  3. Export orphan EmailMessages (WHERE ActivityId=NULL AND ParentId=NULL) to keep as a backup. Note: Once Support removes the orphaned EmailMessage records there is no way to recover or restore them.

Example of data loader query: (Select Id, ParentId, ActivityId, CreatedDate, TextBody FROM EmailMessage WHERE ActivityId = '' AND ParentId = '')



Log a Case with Salesforce Support requesting to delete all persisting orphaned EmailMessage records


Please ask Support to reference this article # 000384885 upon logging your Case and include permission for Support to run the necessary scrutiny to manually clear out and purge all orphaned EmailMessage records.

Note: Deleting a subset of orphaned email messages is not possible. There are no exceptions to this and the process will delete all orphaned email messages.
 
Knowledge 기사 번호

000384885

 
로드 중
Salesforce Help | Article