3

I am reading the content of a file and writing it to a SharePoint external List(SQL). There is around 35000 lines in the file. I am receiving the error below in SharePoint and process memory usage is rising to 1.8GB (This is when error occurs) around 10000 records make it- Is there a more efficient way to write on the client side to use less memory or is there a limit to the amount of data that can be sent to an external SharePoint list at once?

SCRIPT7002: XMLHttpRequest: Network Error 0x2ee4, Could not complete the operation due to error 00002ee4

 function readFile() {     
    /*Access Sharepoint Web*/
    var clientContext;
    var oWebsite;
    var fileUrl;

    clientContext = new SP.ClientContext.get_current();
    oWebsite = clientContext.get_web();
    clientContext.load(oWebsite);
    /*Loads the content of specified text file*/
    //we will declare the text file name to be the most recent added by   

    clientContext.executeQueryAsync(function () {
        fileUrl = oWebsite.get_serverRelativeUrl() + "/MytextFile.txt";
        $.ajax({
            url: fileUrl,
            type: "GET",
            contentType:"application/json; charset=utf-8"
        })
        .done(Function.createDelegate(this, successHandlerrf))
        .error(Function.createDelegate(this, errorHandlerrf));
    }, errorHandler);

    function successHandlerrf(data) {
        var lines = data.split('\n');
        var lineItems = lines.length;
        var lines1 =[];

        for(i;i<=x ;i++){
            lines1 = lines[i].substring(0,14); 
            oListItem.set_item('Document_Number', lines1).trim();
            oListItem.update();
            clientContext.load(oListItem);

            // break;
            clientContext.executeQueryAsync( );
   }
         $('#loading').html('');
         alert("Complete");
           }

1 Answer 1

0

One improvement I can suggest is moving executeQuery to outside the loop.

Once you load all the changes you can make a single call to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.