Newer Version Available

This content describes an older version of this product. View Latest

Delete Field History and Field Audit Trail Data

Use Apex or SOAP to delete field history and field history archive data.

To delete field history and audit trail data, the user permissions Delete From Field History and Delete From Field History Archive must be enabled through a permission set or a user profile. The org preferences to enable these permissions, Delete From Field History and Delete From Field History Archive, are located in Setup | User Interface.

Delete field history data, such as AccountHistory, by passing in a list of ID values as strings using the Apex or SOAP delete() method. The Apex delete() method also works with a list of sObjects with the Id field populated. Delete field history archive data from the FieldHistoryArchive big object using the SOAP deleteByExample() or Apex Database.deleteImmediate() methods.

The sObject acts like a template. All rows that match the sObject’s fields and values are deleted. You can only specify fields that are part of the big object’s index. You must specify all fields in the index. You can’t include a partially specified index or non-indexed field, and wildcards are not supported.

Sample for deleting AccountHistory:

Samples for deleting from FieldHistoryArchive:

Alternatively, delete field history archive data with the SOAP call deleteByExample(). Declare an sObject containing the fields and values in the FieldHistoryArchive big object to delete. This example deletes all rows that meet the specified criteria.

Repeating a successful deleteByExample() operation produces a success result, even if the rows have already been deleted.

Note