Skip to content

Patching Dataverse Records Directly from the Browser Without Plugins

Quite recently, I needed to do some data manipulation in a pinch in one of my heavily restricted Dataverse environments. The environment was only accessible from specific IPs, and the only tool I had available at the time was my browser—no executables allowed!
I could not find an example of how to do this directly from a browser, so it made a good topic for a blog post.
It is possible in the browser! This also means it’s possible to use the same authentication as the browser, with no need to re-authenticate.

Method 1: Patching using the javascript console

I got this one from an old Microsoft support case.

This approach is universally applicable, regardless of the browser you’re using. It’s particularly useful in scenarios where you don’t have access to the built-in tools, such as the network console in Edge.

Your browser might be different, but here is the procedure in Edge.
Open the developer console by hitting Ctrl – Shift – I (Or opening settings – More tools – Developer tools)

Click on the Console button. You might want to clear the console by clicking the clear button left to “top”

Copy this Javascript (Remember to change the values!), paste it into the console, and hit enter.

var queryPath = *Your dataverse instance*/api/data/v9.2/*table you want to patch*(*record GUID*);
var param = {};
param["Column to patch"] = "Column value";
 
var req = new XMLHttpRequest();
 
req.open("PATCH", queryPath, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 
req.onreadystatechange = function () {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 200) {
            alert(this.status);
        }
        else {
            alert(this.status);
        }
    }
};
req.send(JSON.stringify(param));

It should look something like this if all goes well. I have detached the DEV console, it makes I a bit easier to work with.

If you get a “204” alert, that means that it went well and that you patched the record.

Method 2: Using the network console in Edge

This one is a slight twist on the first one. Instead, it uses the network console in Edge’s developer console to create the patch record.
Start by opening the Network console but clicking the Network console icon.

Click on the “Create Request” button. 
Change the method from “GET” to “POST”
Open “Body,” change the type to “Raw text” and enter the column and value as JSON.

{
    "column 1":"value",
    "Column 2":0.01
}


It should look something like this, and as the first example, if it returns 204, it went through.

I hope it makes sense, otherwise, do let me know (-:

Leave a Reply

Your email address will not be published. Required fields are marked *