Restore deleted Dataverse rows with the Recycle Bin(preview)

Any organization that uses any type of system may at some point in time need to delete records or rows from their database(s). This can be for various reasons, like cleaning up data, correcting errors, or following business rules. Another scenario that is possible is that someone deleted a record that was not supposed to be deleted by accident. This can lead to the fact that sometimes you might need to reverse a deletion and restore/recover the data that was removed. If your organization is using Dataverse to build custom apps or if they are using any of the business apps built on Dataverse, then this can be a major problem!
Until today, rows (records) are not recoverable by default. If you (or someone else) deleted a row that needs to be restored, then you’re out of luck, unless you have some sort of backup solution. In this article I will discuss a new feature that is in preview today, which provides recycle bin functionality that allows admins to recover previously deleted rows (records) within a certain time period. 

Enable the preview

Just like with any preview feature, an admin will need to enable this feature before you can try it out. To enable the feature, you’ll need to navigate to the Power Platform Admin Center and open the environment for which you want to turn this on. One you are on the environment page, click on the ‘Settings’ button on the top command bar. Expand the ‘Products’ section on the screen and click ‘Features’.

Scroll down until you see the ‘Recycle Bin’ section close to the bottom of the page. Set the switch ‘Enable Recycle bin for Dataverse tables’ to ‘On’. This will enable this feature for ALL TABLES. Unfortunately, it’s not possible to enable this only for selected tables. I’m hoping that this will change in the future. You’ll notice another field called ‘Configure recovery time interval (up to 30 days)’ below the slider. This setting will determine up to how many days admins will be able to restore deleted rows. The maximum setting is 30 days. Once you have configured these settings, don’t forget to save the changes.

View and restore deleted rows

During the preview period of this feature only users that have the system administrator roles have the ability to view and restore deleted rows. To view a list of the deleted rows you will need to sign into the Power Platform Admin Center. From there you’ll need to navigate to ‘environments’ and open the environment for which you want to view deleted rows. Expand the ‘Data Management’ section on the right side of the screen, then click the ‘View deleted records’ link below it. This will take you to a view that shows all the records that have been deleted (within the time frame you configured earlier). There is only one view available, and the view can’t be changed, nor can you add any additional views. Deleted records from all tables will be visible from this view, as the deleted records are linked to the ‘Deleted Record Reference’ table. There are six columns in the view. The first column is called ‘Display Name’, and it shows the table the record was deleted from, followed by a dash and the name of the deleted row. The next column is called ‘RegardingObjectID’ which I am not sure what this is referring to, as this field stayed blank after I deleted several rows. The ‘Deleted Object’ column shows the name of the row that was deleted. The data in this column shows as a clickable link, however, when you try to click the link to the deleted record, it shows the record is unavailable. The ‘Deleted by’ row shows the (user or system) account that deleted the row. NOTE: When rows are deleted as a result of cascading rules (cascade-delete), you’ll see the ‘SYSTEM’ account populated here.

The ‘Deleted by(Delegate)’ column shows the (user) account that initiated the deletion. NOTE: Using the same example as above, if related rows were deleted as a result of cascading rules, this will show the user who deleted the parent record that started the cascading rule deletion. It is important to understand that when related rows are deleted through cascade behavior, these rows will not show up in the deleted record views. For example, if an account row was deleted that had associated rows, like contacts, opportunities, etc. If these rows have cascading rules configured for them to be deleted when the parent (account) is deleted, then these related rows will not show up in the deleted items view.
Another thing I noticed is that when activities are deleted from Dataverse, an extra row shows up that starts with ‘Activity Party –‘ followed by something that looks like a GUID. When I tried to restore any of these rows I got an error message and was unable to restore them.

Restore deleted rows

The process of restoring deleted rows is very simple. Admins can select one or multiple deleted rows from the list, after which the ‘Restore’ button becomes visible. Clicking the ‘Restore’ button restores the row in the database. Rows that have related rows that were deleted through the cascading rules in the application, will automatically be restored when the parent record is restored. For example, if an account row was deleted that had associated rows, like contacts, opportunities, etc. If these rows have cascading rules configured for them to be deleted when the parent (account) is deleted, then these related rows will also be restored when the parent row (Account) is restored. If you want to leave the account row deleted and you only want to restore any of the related rows, that is not possible today. The only option is to restore the parent record. Another thing to note is that if your organization had added custom logic to delete related records (I.E plugins), you need to apply the opposite logic on the restore operation to recover the rows when you restore the original row that was deleted.
Besides manually restoring deleted rows, developers can also use code to restore deleted rows. To learn more check out this article on Microsoft learn. I hope you enjoyed this article! Be sure to check in again next week for a new article or subscribe here to never miss another post!

Share this!

Leave a Reply