Using the Restore Message to Recover Deleted Records in Dataverse


Accidental data deletion in Dataverse happens more often than we expect. A bulk delete job, an incorrect Power Automate flow, or incorrect manual delete can remove important records in seconds. Instead of restoring the environment, Dataverse provides a much better alternative: the Restore message, which allows us to recover deleted records programmatically.

Prerequisite: Recycle Bin Must Be Enabled

The Restore message works only if the Recycle Bin is enabled for the table before the record is deleted. If the recycle bin is disabled, deleted records are permanently removed and cannot be recovered using the SDK.

When a record is deleted, Dataverse moves it to the recycle bin. We can query these deleted records using RetrieveMultiple with DataSource = “bin” and then pass the deleted record’s ID to the Restore message. The restore operation recreates the record using the same record ID.

Sample Console App

The following console app retrieves deleted Case (incident) records from the recycle bin and restores them using the Restore message.

static void Main(string[] args)
{
    Console.WriteLine("Restore Deleted Records started.");

    string connString = @"AuthType=OAuth;
Username=your.user@tenant.onmicrosoft.com;
Password=********;
Url=https://yourorg.crm.dynamics.com/;
AppId=00000000-0000-0000-0000-000000000000;
RedirectUri=app://58145b91-0c36-4500-8554-080854f2ac97/";

    var serviceClient = new CrmServiceClient(connString);
    var service = serviceClient.OrganizationWebProxyClient
        ?? throw new Exception("Organization service not available");

    // Retrieve deleted records from recycle bin
    QueryExpression query = new QueryExpression("incident")
    {
        ColumnSet = new ColumnSet("title"),
        DataSource = "bin",
        TopCount = 50
    };

    var deletedCases = service.RetrieveMultiple(query);

    if (deletedCases.Entities.Count == 0)
    {
        Console.WriteLine("No deleted records found.");
        return;
    }

    foreach (var deletedCase in deletedCases.Entities)
    {
        Guid caseId = deletedCase.Id;
        string title = deletedCase.GetAttributeValue<string>("title") ?? "Case";

        // Prepare entity for restore
        Entity caseToRestore = new Entity("incident", caseId);
        caseToRestore["title"] = title + " (Restored)";

        // Restore using Restore message
        OrganizationRequest restoreRequest = new OrganizationRequest("Restore");
        restoreRequest["Target"] = caseToRestore;

        service.Execute(restoreRequest);

        Console.WriteLine($"Restored record: {caseId}");
    }

    Console.WriteLine("Deleted records restored successfully.");
}

E.g., we have the following deleted case, and its related records in our recycle bin.

On running our console app, we can see our deleted case records restored.

Get all the details here.

Hope it helps..

Advertisements

Fixing the “Only 1 of 2 keys provided for lookup, provide keys for dataAreaId, ProjectID / Not found” Error in Power Automate (Fin & Ops Apps)


Recently, while working with the Projects table from a Finance & Operations (F&O) environment, we ran into an error while using the Get a record action in Power Automate. (BTW this was the first we were using the Fin & Ops connector)

The flow kept failing with the following message:

Only 1 of 2 keys provided for lookup, provide keys for dataAreaId, ProjectID.

This error appears when we try to fetch a record from an F&O using only the ProjectID. But unlike normal Dataverse tables, F&O tables often come with composite keys.

Instead of passing just the ProjectID, we must pass the full composite key in the format:

dataAreaId,ProjectID

In our case, the correct value was:

AUST P-REP-34

Below, we can see it working properly

A screenshot of a computer

AI-generated content may be incorrect.

At one point, even after passing the correct composite key, we started getting a NotFound error:

Action ‘Get_a_record’ failed – NotFound

A screen shot of a computer error

AI-generated content may be incorrect.

Nothing had changed in the inputs — it was just not working. The fix was surprisingly simple..

We deleted the Get a record step, re-added it, provided the same inputs again, and the error disappeared. It could be related to the connection reference not being updated properly in the background.

Hope it helps..

Advertisements

Troubleshoot “Something happened, and we couldn’t copy to this environment” error – Dataverse /Dynamics 365 


Recently, while trying to copy an environment, we got the following issue –

Something happened, and we couldn’t copy to this environment. Please retry. If the issue continues, go to the Help + support tab. Include this correlation ID: 5e294f10-a784-4cda-881f-37799a37ddbc

At first glance, this seemed serious, especially because it mentioned a correlation ID and hinted at contacting Microsoft support.

In History also we can see it showing the status as failed.

A screenshot of a computer

AI-generated content may be incorrect.

We simply retried the copy operation — and this time, it worked flawlessly.

This indicates that the issue was likely transient, possibly caused by temporary backend resource availability or network hiccups.

Takeaway: Not every red error banner means a deep technical issue. Sometimes, it’s just the system asking for another try.

Hope it helps..

Advertisements

Resolved – Environment Operation Error, while trying to copy environment (Dataverse / Power Platform)


Recently we created a new environment, and when we tried copying our production environment to it, it gave the below error.

“Environment Operation Error -Sorry, something went wrong while requesting the details of an ongoing operation”

A screenshot of a message

AI-generated content may be incorrect.

On trying to open the newly created environment, we got the below error.

“Environment Not Found -The environment was not found. This can happen if you recently performed an operation or switched accounts”

A screenshot of a computer error message

AI-generated content may be incorrect.

Shortly after that, we noticed the environment disappeared from the list of environments in the Power Platform Admin Center. To investigate what might have gone wrong, we raised a support ticket. However, after about an hour, the Admin Center began displaying the newly created environment we were copying to, and upon opening it, we saw the message – “The environment was successfully copied.”

A screenshot of a computer

AI-generated content may be incorrect.

We got the below explanation from Microsoft Support which clarified the behaviour – “If a copy operation begins but does not complete, particularly when using the “Copy over everything” option, the target environment may enter a missing or soft-deleted state. This is a known behavior in Power Platform, where environments can temporarily disappear from the environment list during long-running or interrupted operations.”

Hope it helps..

Advertisements

How We Reclaimed Storage from the WebResourceBase Table in Dataverse


While reviewing our Dataverse environment’s storage usage, we noticed something surprising—over 13 GB of our file capacity was being consumed by the WebResourceBase table alone. This table typically stores JavaScript files, HTML web resources, images, and other files tied to customizations in Dynamics 365. However, the volume was unexpectedly high, prompting us to investigate further.

We started by examining the capacity usage charts available under:

Power Platform Admin Center > Resources > Capacity > File Usage

It was evident that the WebResourceBase table was consistently occupying around 13,027 MB (13 GB), far more than any other table.

Realizing that this wasn’t just normal customization data, we raised a support request with Microsoft to understand what was happening behind the scenes.

After a quick investigation, Microsoft Support responded with the following:

“Upon review, we have found that the WebResourceBase table is indeed occupying a significant amount of storage—13.027 GB. There are instances of ‘orphaned’ WebResourceBase records, which can occur due to solution uninstalls or as leftover artifacts from other entities that depend on WebResources. To address this issue, we can run a script to remove these orphaned web resources, which will help in reducing the storage used in your environment.”

These “orphaned” records are essentially detached or unused web resources—files that are no longer tied to any solution or customization but remain in storage. They commonly appear in environments where unmanaged solutions are frequently installed and removed.

Upon our approval, Microsoft executed a backend script to safely identify and remove these orphaned entries.

Post-Cleanup Results –

Before: 13,027 MB

After: 10009MB

Recovered: 3,018 MB (~3 GB)

A screenshot of a computer

AI-generated content may be incorrect.

This led to around a 24 percent reduction in the file capacity used by the WebResourceBase table.

Microsoft also confirmed that no further reduction was possible at this time—the remaining content is either actively referenced or structurally required by the platform.

Hope it helps..

Advertisements

The async operation was skipped because the org is in “Disable Background Processing” mode – Dataverse / Dynamics 365


While testing one scenario we observed one of the plugins (asynchronous) was not updating the record as expected.

Checking the System Jobs, we saw the below error.

The async operation was skipped because the org is in “Disable Background Processing” mode.

Well, this was because we had recently created this environment by copying our UAT environment and had forgotten to disable the Admin mode / enable Background operations.

A screenshot of a computer screen

AI-generated content may be incorrect.

Get more details – Administration Mode.

Hope it helps..