I have a issue with a bit of code and Chrome, I have this function below that takes the array softArr and adds each item to a sharepoint list

function testAdd(softArr) {

console.log("Entered testAdd");
var siteUrl = 'https://mysiteExample';
var batch = 0;

var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('myfirstList');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
for (var counter = 0; counter < softArr.length; counter++) {
    this.oListItem = oList.addItem(itemCreateInfo);

    oListItem.set_item('Title', "N/A");
    oListItem.set_item('Applicationfamily', softArr[counter][0]);
    oListItem.set_item('Application', softArr[counter][1]);
    oListItem.set_item('SoftwareClass', softArr[counter][2]);
    oListItem.set_item('Manufacturer', softArr[counter][3]);
    oListItem.set_item('PartofBundle', softArr[counter][4]);
    oListItem.set_item('License', softArr[counter][5]);
    oListItem.set_item('TAG', softArr[counter][6]);
    oListItem.set_item('Status', softArr[counter][7]);
    oListItem.set_item('Description', softArr[counter][8]);
    oListItem.set_item('Sponsor', softArr[counter][9]);



    if (batch == 100) {
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

        batch = 0



clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));


Now this code works for the most part however it doesn't work in chrome it's will get to 1350 rows entered into the list and then give an error ERR_INSUFFICIENT_RESOURCES. This error doesn't happen in edge. I've also tried lowering the resource usage on my machine and that does nothing.

Also if I move the clientContext.executeQueryAsync function outside of the for-loop I get The server does not allow messages larger than 2097152 bytes error.

if anyone has any ideas around this that would be really helpful.

  • Hello, this.oListItem = oList.addItem(itemCreateInfo) should be inside the for loop. Next, define a batch size (maybe 100), and call clientContext.executeQueryAsync once you have the batch size items in queue. It should help you to go through your items. Let me know if this doesn't help. Also, you can try setting MaxReceivedMessageSize and MaxParseMessageSize properties to a higher number.
    – UBK
    Apr 29 '20 at 22:00
  • @UBK Thanks so much this work great I batched up my items into 100s please look at my code edit and let me know if there are any glaring issues Apr 30 '20 at 8:20
  • Hi, please up vote the comment if it helped. Your code looks fine to me.
    – UBK
    Apr 30 '20 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.