Error Threshold 5000 records Sharepoint Online 2013

0

I have an application developed in angular and I use Sharepoint Online 2013 to save and consult data.

I have the following block of code.

    vm.liberadosGridOptions = {

                dataSource: new kendo.data.DataSource({

                    pageSize: 10,
                    serverFiltering: true,
                    transport: {
                        read: {
                            url: "../_api/web/lists/GetByTitle('Lista')/items?$select=*,Cliente/Id&$expand=Cliente",

                            beforeSend: function (xhr) {
                                xhr.setRequestHeader('Accept', "application/json;odata=verbose");
                            },
                            data: function () {

                                return {
                                    $filter: "(Estado1 eq '1' or Estado2 eq 'Liberado 0') and Cliente/Id eq '" + vm.Cliente.Id + "'",
                                    $top: "5000"

                                };
                            }
                        },
                        dataType: "JSON",

I already put the top of 5000 but just ignores it and generates this error

{
    "odata.error": {
        "code": "-2147024860, Microsoft.SharePoint.SPQueryThrottledException",
        "message": {
            "lang": "es-ES",
            "value": "Se intentó una operación que está prohibida porque supera el umbral de vista de lista aplicado por el administrador."
        }
    }
}
    
asked by Eduard 11.09.2017 в 21:23
source

2 answers

1

You can send the filters you need in the url, something like that.

            dataSource: new kendo.data.DataSource({

                pageSize: 10,
                serverFiltering: true,
                transport: {
                    read: {
                        url: "../_api/web/lists/GetByTitle('Lista')/items?$select=*,Cliente/Id&$expand=Cliente&$filter=(Estado1 eq '1' or Estado2 eq 'Liberado 0') and Cliente/Id eq '" + vm.Cliente.Id + "'",

                        beforeSend: function (xhr) {
                            xhr.setRequestHeader('Accept', "application/json;odata=verbose");
                        },
                        data: function () {

                           //
                        }
                    },
                    dataType: "JSON",
    
answered by 05.02.2018 / 19:24
source
1

The problem still occurs because in reality the top filter is done after obtaining the elements of the database. The problem of 5000 elements is just not being able to handle more than 5000 elements through the same operation in the same table in the bd.

Therefore, try to perform the filter by Ids. In my case, I always take the first Id and the last one with two previous orders using the following filter: ?$top=1&$orderby=Id and ?$top=1&$orderby=Id desc respectively.

Then, I divide the difference by a number less than 5000, and I make so many independent orders according to the result of that ratio by filtering through the range of Ids.

Greetings

    
answered by 21.09.2017 в 20:31