Editar

Compartilhar via


Retrieve and delete the history of audited data changes

After auditing is enabled and data changes are made to those entities and attributes being audited, you can proceed to obtain the data change history. Optionally, you can delete the audit records after you review the change history. Follow the sample code link at the end of this topic for more information.

Retrieve the change history

There are several messages requests that can be used to retrieve the audit change history. These requests are differentiated by the nature of what they retrieve.

Refer to the sample link at the end of this topic for sample code that demonstrates some of these change history message requests.

Delete the change history for a record

Use the DeleteRecordChangeHistoryRequest message to delete all the audit change history records for a particular record. This lets you delete the audit change history for a record instead of deleting all the audit records for a date range, which is covered in the next section. To delete the audit change history for a record, you must have a security role with the prvDeleteRecordChangeHistory privilege or be a System Administrator.

Delete the change history for a date range

You can delete audit records for a date range using the DeleteAuditDataRequest request. Audit data records are deleted sequentially from the oldest to the newest. The functionality of this request is slightly different based on the edition of SQL Server being used by your Dynamics 365 Customer Engagement (on-premises) server. Dynamics 365 for Customer Engagement uses an enterprise edition of SQL Server.

If your Dynamics 365 Customer Engagement (on-premises) server uses SQL Server standard edition, which does not support the database partitioning feature, the DeleteAuditDataRequest request deletes all audit records created up to the end date specified in the EndDate property.

If your Dynamics 365 Customer Engagement (on-premises) server uses an Enterprise edition of SQL Server that does support partitioning, the DeleteAuditDataRequest request will delete all audit data in those partitions where the end date is before the date specified in the EndDate property. Any empty partitions are also deleted. However, neither the current (active) partition nor the audit records in that active partition can be deleted by using this request or any other request.

New partitions are automatically created by the Dynamics 365 Customer Engagement (on-premises) platform on a quarterly basis each year. This functionality is non-configurable and cannot be changed. You can obtain the list of partitions using the RetrieveAuditPartitionListRequest request. If the end date of any partition is later than the current date, you cannot delete that partition or any audit records in it.

See also

Data Management in Dynamics 365 Customer Engagement (on-premises)
Audit entity data changes
Audit user access
Sample: Audit Entity Data Changes

Auditing Entity Data Changes in Dynamics 365 Customer Engagement (on-premises)