Sort a list block by a field whose name is specified in a URL querystring parameter

Here’s some example code that pulls a sort field from the URL querystring and substitutes it into the request for the list data, so that the net effect is that you can load and the list block on that page will sort by the Email column instead of whatever was originally specified in the list block.

    const urlParams = new URLSearchParams(;
    const sortingField = urlParams.get('sortingField');
    if (sortingField) {
        (function(send) {
              XMLHttpRequest.prototype.send = function() {
                if (typeof arguments[0] === "string") {
                    var b = JSON.parse(arguments[0]);
                    b.sortingOption.sortingField = sortingField;
                    const body = JSON.stringify(b);
                    arguments[0] = body;
                send.apply(this, arguments);

Note: the data will not display if the value of the sortingField querystring parameter is not a valid field name.


I also figured out how to make the URL query string track changes to list search and filters. Please reply if you want that code.