Intro
Have you deleted some Dataverse records accidentally and you're struggling how to managed it ?
The new Recycle Bin feature in preview might be what it solves your problem.
It allows Administrator only (in the preview version) to recover user deleted records up to 30 days!
How it Works
First we need to ensure that the feature is activated doing it this way_
- Going to the Settings -> Product -> Features in the admin center
- Trying to set a recovery interval bigger that 30 days will fail !
Second to view and restore the deleted records:
- Go to your environment Settings -> Data Management -> View Deleted Records
- And in this view will be able to view and restore all deleted records
Third, you can also use the Organisation Service in .net or the WebApi to:
- Retrieve deleted records (web api example)
$query = @()
$query += "<fetch top='3' datasource='bin'>"
$query += "<entity name='account'>"
$query += "<attribute name='name' />"
$query += "</entity>"
$query += "</fetch>"
$uri = $environmentUrl
$uri += 'accounts'
$uri += '?fetchXml=' + [uri]::EscapeUriString($query -join '')
$RetrieveMultipleRequest = @{
Uri = $uri
Method = 'Get'
Headers = $baseHeaders
}
Invoke-RestMethod @RetrieveMultipleRequest
- Restore deleted records (.net example)
/// <summary>
/// Restores an account record
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
/// <param name="accountId">The ID of the deleted account record.</param>
/// <param name="originalName">The original name value for the account record.</param>
/// <returns>The ID of the restored account</returns>
static Guid RestoreAccountRecordEarlyBound(
IOrganizationService service,
Guid accountId,
string originalName)
{
Account accountToRestore = new()
{
Id = accountId,
// Appending '(Restored)' to the original name
// to demonstrate overwriting a value.
Name = originalName + " (Restored)"
};
RestoreRequest<Account> request = new()
{
Target = accountToRestore
};
var response = (RestoreResponse)service.Execute(request);
return response.id;
}
Points in atenttion
- Not all tables are enabled for Recycle bin and Solution components, virtual tables, and elastic tables aren't supported for recycle bin operations
- Here's a list of tables that don't support recycle bin https://learn.microsoft.com/en-us/power-apps/developer/data-platform/restore-deleted-records?tabs=sdk#tables-not-currently-supported-for-recycle-bin
- Records deleted through a relationship behavior (Cascade All) aren't recovered when the parent record is restored and this must be managed independently by doing a manual restore of the cascaded records or via a plugin
Final thoughts
The Dataverse Recycle bin it's a must to regarding business data recovery and we can't wait for the final announce of it's general availability.
Add new comment