Skip to content

Commit b673fae

Browse files
authored
Merge pull request #5824 from MicrosoftDocs/phecke-auditing-update
Delete audit data using BulkDelete
2 parents c61a935 + dfbf660 commit b673fae

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

powerapps-docs/developer/data-platform/retrieve-and-delete-the-history-of-audited-data-changes.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,63 @@ Refer to the sample link at the end of this topic for sample code that demonstra
4545

4646
If your Dataverse server uses an Enterprise edition of SQL Server that does support partitioning, the <xref:Microsoft.Crm.Sdk.Messages.DeleteAuditDataRequest> request will delete all audit data in those partitions where the end date is before the date specified in the <xref:Microsoft.Crm.Sdk.Messages.DeleteAuditDataRequest.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.
4747

48-
New partitions are automatically created by the Dataverse 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 <xref:Microsoft.Crm.Sdk.Messages.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.
48+
New partitions are automatically created by the Dataverse 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 <xref:Microsoft.Crm.Sdk.Messages.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.
49+
50+
## Delete audit data flexibly using BulkDelete
51+
52+
You can delete audit records your organization no longer needs to retain to comply with internal and external auditing requirements using the [BulkDelete](xref:Microsoft.Dynamics.CRM.BulkDelete) action in the Web API or the [BulkDelete](xref:Microsoft.Crm.Sdk.Messages.BulkDeleteRequest) message in the Organization Service. Deleting audit data using bulk delete will run in the background and allows you to define recurrence patterns, start time, and other parameters that help you to manage your bulk deletion jobs.
53+
54+
### Basic audit bulk delete example
55+
56+
This basic example deletes audit records of type 64 (User Access via Web) from the audit log. You can find the full list of audit actions in the [audit entity reference](reference/entities/audit.md) and modify your bulk delete job according to your needs.
57+
58+
**Request**
59+
60+
```http
61+
POST [Organization URI]/api/data/v9.1/BulkDelete HTTP/1.1
62+
Accept: application/json
63+
OData-MaxVersion: 4.0
64+
OData-Version: 4.0
65+
66+
{
67+
"QuerySet":
68+
[
69+
{
70+
"EntityName": "audit",
71+
"Criteria": {
72+
"FilterOperator": "And",
73+
"Conditions": [
74+
{
75+
"AttributeName": "action",
76+
"Operator": "Equal",
77+
"Values": [ {"Type": "System.String", "Value": "64"} ]
78+
}
79+
],
80+
"Filters": []
81+
}
82+
}
83+
],
84+
"JobName": "Bulk Delete of audit records with action = 64",
85+
"SendEmailNotification": false,
86+
"ToRecipients": [],
87+
"CCRecipients": [],
88+
"RecurrencePattern": "",
89+
"StartDateTime": "2022-02-02T10:00:00.000Z"
90+
}
91+
```
92+
93+
**Response**
94+
95+
```HTTP
96+
HTTP/1.1 200 OK
97+
Content-Type: application/json; odata.metadata=minimal
98+
OData-Version: 4.0
99+
100+
{
101+
"@odata.context": "[Organization URI]/api/data/v9.0/$metadata#Microsoft.Dynamics.CRM.BulkDeleteResponse",
102+
"JobId": "[Job Id]"
103+
}
104+
```
49105

50106
### See also
51107

0 commit comments

Comments
 (0)