You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/data-platform/restore-deleted-records.md
+27-29Lines changed: 27 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Sometimes people delete records that they shouldn't. Administrators can enable a
25
25
## Retrieve deleted records that can be restored
26
26
27
27
To retrieve deleted records that can be restored, set the datasource of the query to '`bin`'.
28
-
The examples below return up to 3 deleted account records.
28
+
The following examples return up to three deleted account records.
29
29
30
30
### [SDK for .NET](#tab/sdk)
31
31
@@ -109,17 +109,17 @@ function Get-DeletedAccountRecords{
109
109
110
110
## Restore a deleted record
111
111
112
-
Use the `Restore` message to restore a deleted record. The `Target` parameter is not a reference to a deleted record, it's a full record so you can set column values while you restore the record. All the original column values are restored unless you override them by setting values during the `Restore` operation.
112
+
Use the `Restore` message to restore a deleted record. The `Target` parameter isn't a reference to a deleted record, it's a full record so you can set column values while you restore the record. All the original column values are restored unless you override them by setting values during the `Restore` operation.
113
113
114
114
> [!NOTE]
115
115
> At this time you can only restore records using the primary key value. You can't use an alternate key to restore a record.
116
116
117
117
118
-
How you restore a deleted record depends on whether you are using the SDK for .NET or Web API.
118
+
How you restore a deleted record depends on whether you're using the SDK for .NET or Web API.
119
119
120
120
### [SDK for .NET](#tab/sdk)
121
121
122
-
How you restore a record using the SDK for .NET depends on whether you are generating early bound types using [pac modelbuilder](/power-platform/developer/cli/reference/modelbuilder), or if you are using the late bound stye.
122
+
How you restore a record using the SDK for .NET depends on whether you're generating early bound types using [pac modelbuilder](/power-platform/developer/cli/reference/modelbuilder), or if you're using the late bound style.
123
123
124
124
[Learn about late-bound and early-bound programming using the SDK for .NET](org-service/early-bound-programming.md)
125
125
@@ -206,7 +206,7 @@ Use the [Restore action](/power-apps/developer/data-platform/webapi/reference/re
206
206
207
207
#### Restore any type of record without overwriting column values
208
208
209
-
This `Restore-AnyRecord` PowerShell function shows how any type record can be restored by referencing it using the full URL to the record and the `@odata.id` annotation. Pass a relative URL like `contacts(0ad63f65-990d-ef11-9f89-6045bdece8bb)` to the `relativeUri` parameter of this function. However, with this approach you can't overwrite any values for the record.
209
+
This `Restore-AnyRecord` PowerShell function shows how any type record can be restored by referencing it using the full URL to the record and the `@odata.id` annotation. Pass a relative URL like `contacts(0ad63f65-990d-ef11-9f89-6045bdece8bb)` to the `relativeUri` parameter of this function. However, with this approach you can't overwrite any values for the record.
210
210
211
211
```powershell
212
212
function Restore-AnyRecord{
@@ -244,8 +244,8 @@ function Restore-AnyRecord{
244
244
245
245
This `Restore-AccountRecord` PowerShell function shows how to restore an account record and overwrite a value. There are three requirements:
246
246
247
-
-[Specify the table type parameter](webapi/use-web-api-actions.md#specify-the-table-type-parameter) using the `@odata.type` with the fully qualified name of the entity type. This tells OData what type of record it is.
248
-
-Include the primary key value, in this case `accountid`to specify the record.
247
+
-[Specify the table type parameter](webapi/use-web-api-actions.md#specify-the-table-type-parameter) using the `@odata.type` with the fully qualified name of the entity type. This annotation tells OData what type of record it is.
248
+
-To specify the record, include the primary key value, in this case `accountid` .
249
249
- Specify any properties you want to overwrite, in this case the `name` property.
250
250
251
251
@@ -289,9 +289,9 @@ function Restore-AccountRecord {
289
289
290
290
---
291
291
292
-
### Errors that may occur when restoring records
292
+
### Errors that might occur when restoring records
293
293
294
-
The following errors may occur when restoring records.
294
+
The following errors might occur when restoring records.
295
295
296
296
#### RefCannotBeRestoredRecycleBinNotFound
297
297
@@ -334,7 +334,7 @@ The following errors may occur when restoring records.
334
334
335
335
If the record with same primary key was already deleted before, copy to Recycle Bin is ignored for the record. To enforce all deleted items are stored in Recycle Bin, you can set the `DoNotEnforcePrimaryKeyOrgSettingRecycleBin` setting using the [OrgDBOrgSettings tool for Microsoft Dynamics CRM](/power-platform/admin/environment-database-settings).
336
336
337
-
After enabling this, you may receive the following error:
337
+
After enabling this setting, you might receive the following error:
@@ -343,13 +343,13 @@ After enabling this, you may receive the following error:
343
343
344
344
## Detect which tables are enabled for recycle bin
345
345
346
-
Before the recycle bin feature is enabled, the [Recycle Bin Configuration (RecycleBinConfig) table](reference/entities/recyclebinconfig.md)will have no rows.
346
+
Before the recycle bin feature is enabled, the [Recycle Bin Configuration (RecycleBinConfig) table](reference/entities/recyclebinconfig.md)has no rows.
347
347
348
-
In time, we expect that eventually all tables will be available to use the recycle bin feature. During this preview, some tables do not. For a list of tables that do not support recycle bin, see [Tables not currently supported for Recycle Bin](#tables-not-currently-supported-for-recycle-bin).
348
+
In time, we expect that eventually all tables will be available to use the recycle bin feature. During this preview, some tables don't. For a list of tables that don't support recycle bin, see [Tables not currently supported for Recycle Bin](#tables-not-currently-supported-for-recycle-bin).
349
349
350
-
You can also [disable recycle bin for specific tables](#disable-recycle-bin-for-a-table) and [disable recycle bin for the environment](#disable-recycle-bin-for-the-environment). If the recycle bin isn't enabled for a table, you will not [find any records eligible to be restored](#retrieve-deleted-records-that-can-be-restored), but you can also query Dataverse to find out whether the recycle bin is enabled for a table or not.
350
+
You can also [disable recycle bin for specific tables](#disable-recycle-bin-for-a-table) and [disable recycle bin for the environment](#disable-recycle-bin-for-the-environment). If the recycle bin isn't enabled for a table, you won't [find any records eligible to be restored](#retrieve-deleted-records-that-can-be-restored). You can query Dataverse to find out whether the recycle bin is enabled for a table or not.
351
351
352
-
Tables that are enabled for recycle bin will have a row in the `RecycleBinConfig` table where the `statecode` is active and `isreadyforrecyclebin` is true. The `RecycleBinConfig` table doesn't contain the name of the table, but refers to a row in the [Entity table](reference/entities/entity.md) where the `logicalname` column contains the [LogicalName](/dotnet/api/microsoft.xrm.sdk.metadata.entitymetadata.logicalname) of the table.
352
+
Tables that are enabled for recycle bin have a row in the `RecycleBinConfig` table where the `statecode` is active and `isreadyforrecyclebin` is true. The `RecycleBinConfig` table doesn't contain the name of the table, but refers to a row in the [Entity table](reference/entities/entity.md) where the `logicalname` column contains the [LogicalName](/dotnet/api/microsoft.xrm.sdk.metadata.entitymetadata.logicalname) of the table.
353
353
354
354
Use the following FetchXml query to detect which tables have recycle bin enabled:
355
355
@@ -378,9 +378,9 @@ Use the following FetchXml query to detect which tables have recycle bin enabled
378
378
379
379
[Learn to query data using FetchXml](fetchxml/overview.md)
380
380
381
-
## Detect which tables do not have recycle bin enabled
381
+
## Detect which tables don't have recycle bin enabled
382
382
383
-
To know which tables are not enabled for recycle bin, use the following FetchXml query that is the reverse of the one found in [Detect which tables are enabled for recycle bin](#detect-which-tables-are-enabled-for-recycle-bin).
383
+
To know which tables aren't enabled for recycle bin, use the following FetchXml query that is the reverse of the one found in [Detect which tables are enabled for recycle bin](#detect-which-tables-are-enabled-for-recycle-bin).
384
384
385
385
```xml
386
386
<fetch>
@@ -411,12 +411,12 @@ To know which tables are not enabled for recycle bin, use the following FetchXml
411
411
412
412
[Learn to query data using FetchXml](fetchxml/overview.md)
413
413
414
-
The results of this query as of May, 2024 when this preview feature began are in [Tables not currently supported for Recycle Bin](#tables-not-currently-supported-for-recycle-bin)
414
+
The results of this query as of May 2024 when this preview feature began are in [Tables not currently supported for Recycle Bin](#tables-not-currently-supported-for-recycle-bin)
415
415
416
416
417
417
## Retrieve and set the automatic cleanup time period configuration for the recycle bin
418
418
419
-
The value to determine how long deleted records will be available to be restored is set in the [RecycleBinConfig.CleanupIntervalInDays](reference/entities/recyclebinconfig.md#BKMK_CleanupIntervalInDays) column where the [Name](reference/entities/recyclebinconfig.md#BKMK_Name) column value is `organization`. Every other row in the `RecycleBinConfig` table has a `CleanupIntervalInDays` column value of -1. This indicates it will use the same values set for the `organization` table.
419
+
The value to determine how long deleted records are available to be restored is set in the [RecycleBinConfig.CleanupIntervalInDays](reference/entities/recyclebinconfig.md#BKMK_CleanupIntervalInDays) column where the [Name](reference/entities/recyclebinconfig.md#BKMK_Name) column value is `organization`. Every other row in the `RecycleBinConfig` table has a `CleanupIntervalInDays` column value of `-1`. This value indicates it uses the same values set for the `organization` table.
420
420
421
421
To specify a different value for another table, set the `CleanupIntervalInDays` column value where the `Name` matches the logical name of the table. While this column allows values up to 2,147,483,647, we recommend not setting it higher than 30.
422
422
@@ -520,10 +520,10 @@ function Set-CleanupIntervalInDays{
520
520
521
521
## Disable recycle bin for a table
522
522
523
-
To disable the recycle bin for a table, disable the `recyclebinconfig` record for the table by setting the [statecode](reference/entities/recyclebinconfig.md#BKMK_statecode) and [statuscode](reference/entities/recyclebinconfig.md#BKMK_statuscode) properties to their **Inactive** values: 2 and 1 respectively.
523
+
To disable the recycle bin for a table, disable the `recyclebinconfig` record for the table by setting the [statecode](reference/entities/recyclebinconfig.md#BKMK_statecode) and [statuscode](reference/entities/recyclebinconfig.md#BKMK_statuscode) properties to their **Inactive** values: `2` and `1` respectively.
524
524
525
525
> [!NOTE]
526
-
> The queries below compare the `LogicalName` value against the [Entity.Name](reference/entities/entity.md#BKMK_Name) column value, which stores the table `SchemaName`. `LogicalName` is the lower-case version of the `SchemaName`. String value comparisons are case insensitive, so it does't matter which format of name you use.
526
+
> The following queries compare the `LogicalName` value against the [Entity.Name](reference/entities/entity.md#BKMK_Name) column value, which stores the table `SchemaName`. `LogicalName` is the lower-case version of the `SchemaName`. String value comparisons are case insensitive, so it does't matter which format of name you use.
Use this `Disable-RecycleBinForTable` PowerShell function to disable the recycle bin for a specific table. This function depends on the `Get-Records` and `Update-Record` functions described in [Create table operations functions](webapi/use-ps-and-vscode-web-api.md#create-table-operations-functions)
581
+
Use this `Disable-RecycleBinForTable` PowerShell function to disable the recycle bin for a specific table. This function depends on the `Get-Records` and `Update-Record` functions described in [Create table operations functions](webapi/use-ps-and-vscode-web-api.md#create-table-operations-functions)
582
582
583
583
584
584
```powershell
@@ -621,15 +621,15 @@ function Disable-RecycleBinForTable {
621
621
622
622
## Disable recycle bin for the environment
623
623
624
-
Delete the row in the [RecycleBinConfig](reference/entities/recyclebinconfig.md) table where the `name` value is `"organization"`. This will trigger deleting all the records in the `RecycleBinConfig` table and disable recycle bin for the environment.
624
+
Delete the row in the [RecycleBinConfig](reference/entities/recyclebinconfig.md) table where the `name` value is `"organization"`. This triggers deleting all the records in the `RecycleBinConfig` table and disable recycle bin for the environment.
625
625
626
626
> [!IMPORTANT]
627
627
> Don't try to delete individual records. It is important that Dataverse manage this.
628
628
629
629
630
630
## Manage restoring records deleted by custom business logic
631
631
632
-
Dataverse provides a mechanism to manage desired actions for related records when a row is deleted. This is part of the definition of the relationship. When a related record is deleted, there are four possible behaviors that you can configure:
632
+
Dataverse provides a mechanism to manage desired actions for related records when a row is deleted. This configuration data is part of the definition of the relationship. When a related record is deleted, there are four possible behaviors that you can configure:
633
633
634
634
|Delete Behavior|Description|
635
635
|---------|---------|
@@ -640,23 +640,21 @@ Dataverse provides a mechanism to manage desired actions for related records whe
640
640
641
641
[Learn more about relationship behaviors](../../maker/data-platform/create-edit-entity-relationships.md#behaviors)
642
642
643
-
If you have a relationship configured to use the **Cascade All** behavior, all the related records that are deleted will be restored when the deleted record is restored. There is nothing to do because Dataverse manages this.
643
+
There's nothing to do when the relationship is configured for **Cascade All**, **Remove Link**, and **Restrict**because Dataverse manages these behaviors.
644
644
645
-
If you have a relationship configured to use the **Remove Link** behavior, the related records lookup column values are set back to refer to the restored record.
646
-
647
-
If you have a relationship configured to use the **Cascade None** behavior, you may have custom logic that applies some custom behavior. For example, you may wish to respond to this differently and implement your own *'Cascade some'* behavior based on rules you define. For example, you might delete inactive records or records that haven't been updated in a certain period of time. This logic is usually implemented using a plug-in, but it could also be done using Power Automate with the [Microsoft Dataverse connector: When a row is added, modified or deleted trigger](/connectors/commondataserviceforapps/#when-a-row-is-added,-modified-or-deleted).
645
+
If you have a relationship configured to use the **Cascade None** behavior, you might have custom logic that applies some custom behavior. For example, you might wish to respond to this behavior differently and implement your own *'Cascade some'* behavior based on rules you define. For example, you might delete inactive records or records that haven't been updated in a certain period of time. This logic is usually implemented using a plug-in, but it could also be done using Power Automate with the [Microsoft Dataverse connector: When a row is added, modified or deleted trigger](/connectors/commondataserviceforapps/#when-a-row-is-added,-modified-or-deleted).
648
646
649
647
If you have this kind of custom business logic, then Dataverse doesn't know about it and can't automatically 'un-do' your logic. However, you can register another plug-in on the `Restore` message to reverse whatever custom logic you have. Or you could use Power Automate and the [Microsoft Dataverse connector: When an action is performed trigger](/connectors/commondataserviceforapps/#when-an-action-is-performed).
650
648
651
649
652
650
### TODO Plug-in example?
653
651
654
-
The relationships between Account or Contact and activityparty ([account_activity_parties](reference/entities/account.md#BKMK_account_activity_parties) and [contact_activity_parties](reference/entities/contact.md#BKMK_contact_activity_parties) ) are configured with `NoCascade` for Delete by default. Seems like these may be common candidates for people having custom plug-in logic.
652
+
The relationships between Account or Contact and activityparty ([account_activity_parties](reference/entities/account.md#BKMK_account_activity_parties) and [contact_activity_parties](reference/entities/contact.md#BKMK_contact_activity_parties) ) are configured with `NoCascade` for Delete by default. Seems like these might be common candidates for people having custom plug-in logic.
655
653
656
654
657
655
## Tables not currently supported for Recycle Bin
658
656
659
-
The following tables are the result of the query found in [Detect which tables do not have recycle bin enabled](#detect-which-tables-do-not-have-recycle-bin-enabled) in May of 2024 when the preview of this feature started.
657
+
The following tables are the result of the query found in [Detect which tables don't have recycle bin enabled](#detect-which-tables-dont-have-recycle-bin-enabled) in May of 2024 when the preview of this feature started.
0 commit comments