You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何部分数据无法写入SharePoint列表?批量导入故障求助

Troubleshooting SharePoint List Import Failures After 515 Rows

Let's break down why your import is failing after the first 515 records and fix this step by step.

Root Cause Analysis

The error Column '' does not exist is a critical clue here. Looking at your code, you're using index position to map contentArray entries to columnArray when setting SharePoint list items:

self.oListItem.set_item(columnArray[i1], contentArray[i1].FieldValue);

This only works if every FormFieldsList in your JSON data has exactly the same number of fields, in exactly the same order, as your columnArray.

When you hit records with an EPOCH time >1523302307, it’s almost certainly because:

  1. Some of these records have extra fields in FormFieldsList that exceed the length of columnArray (so columnArray[i1] returns undefined, which becomes an empty string in the SharePoint API call)
  2. Or, some fields are missing from FormFieldsList, causing you to map values to the wrong column names
  3. Additionally, calling clientContext.executeQueryAsync() inside the $.each(data) loop sends a separate API request for every single item. This can trigger SharePoint’s request throttling or concurrency limits after a certain number of calls.

Fixes to Implement

1. Replace Index-Based Mapping with Name-Based Mapping

Instead of relying on field order, map fields using their actual names (assuming your FormFieldsList entries include a FieldName property—standard in most form APIs).

First, create a clear mapping between source field names and SharePoint column internal names:

// Map source field names to SharePoint column internal names
var fieldMap = {
  "Quandrant": "Quandrant",
  "MapNumber": "MapNumber",
  "Picture1": "Picture1",
  "Picture2": "Picture2",
  "PoleOwner": "PoleOwner",
  "PoleClass": "PoleClass",
  "PoleSize": "PoleSize",
  "PowerTagNumber": "PowerTagNumber",
  "TelephoneTagNumber": "TelephoneTagNumber",
  "AttachmentHeight": "AttachmentHeight",
  "Guying": "Guying",
  "StreetLightAttached": "StreetLightAttached",
  "TransformerPole": "TransformerPole",
  "ExistingFiber": "ExistingFiber",
  "ExistingCopper": "ExistingCopper",
  "Grounds": "Grounds",
  "MR1AtMidspanClearanceViolation": "MR1AtMidspanClearanceViolation",
  "MR1ClearanceViolation": "MR1ClearanceViolation",
  "MR2PoleTransferRequired": "MR2PoleTransferRequired",
  "MR3DownguyOrAnchorDeficiency": "MR3DownguyOrAnchorDeficiency",
  "MR4BrokenLashingWire": "MR4BrokenLashingWire",
  "MR5DamagedOrKinkedCoaxOrFiber": "MR5DamagedOrKinkedCoaxOrFiber",
  "MR6DropTransferRequired": "MR6DropTransferRequired",
  "MR7TemporaryCoaxOrFiberCable": "MR7TemporaryCoaxOrFiberCable",
  "MR8DamagedElectronics": "MR8DamagedElectronics",
  "MR9PlaceOrRepairGroundOrBond": "MR9PlaceOrRepairGroundOrBond",
  "MR10DrpSplttrOrInsfntTapPrts": "MR10DrpSplttrOrInsfntTapPrts",
  "MR11PedOrVltOrLockbxDmged": "MR11PedOrVltOrLockbxDmged",
  "PoleReplacement": "PoleReplacement",
  "PoleGrade": "PoleGrade",
  "HouseCount": "HouseCount",
  "BuildingInformation": "BuildingInformation"
};

Update your inner loop to use this mapping to avoid invalid column references:

$.each(contentArray, function(i1, item2) {
  var spColumnName = fieldMap[item2.FieldName];
  if (spColumnName) {
    self.oListItem.set_item(spColumnName, item2.FieldValue);
    console.log(`Set ${spColumnName} to ${item2.FieldValue}`);
  } else {
    console.warn(`Skipping unknown field: ${item2.FieldName}`);
  }
});

2. Batch SharePoint API Requests

Calling executeQueryAsync() for every item is inefficient and risky. Instead, batch all operations into a single request:

function testDatabase() { 
  var settingObj = { 
    sinceDateTime: '0', 
    dynoCode: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx', 
    custCode: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx', 
    formGUID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx', 
    getJSONURL: 'https://www.xxxxxxxxxx.net/api/api/xxxx' 
  }; 

  var fieldMap = { /* ... paste the mapping from above ... */ };

  $.getJSON(settingObj.getJSONURL, { 
    sinceDateTime: settingObj.sinceDateTime, 
    custCode: settingObj.custCode, 
    dynoCode: settingObj.dynoCode, 
    formGUID: settingObj.formGUID 
  }).done(function (data) { 
    var clientContext = new SP.ClientContext(siteUrl); 
    var oList = clientContext.get_web().get_lists().getByTitle('testlist2'); 
    var itemCreateInfo = new SP.ListItemCreationInformation(); 

    // Add all item operations to the context first
    $.each(data, function (i, item) { 
      var contentArray = item.FormFieldsList; 
      var oListItem = oList.addItem(itemCreateInfo); 
      oListItem.set_item('Title', item.resourceName); 
      oListItem.set_item('SinceDateTime', item.FormUpdatedDate); 

      $.each(contentArray, function(i1, item2) { 
        var spColumnName = fieldMap[item2.FieldName];
        if (spColumnName) {
          oListItem.set_item(spColumnName, item2.FieldValue);
        } else {
          console.warn(`No SharePoint column found for source field: ${item2.FieldName}`);
        }
      }); 

      oListItem.update(); 
      clientContext.load(oListItem); 
    }); 

    // Execute all operations in one batch
    clientContext.executeQueryAsync(function() {
      console.log(`Successfully created ${data.length} items!`);
    }, onQueryFailed);

    console.log('Rows returned: ' + data.length); 
  }).fail(function (jqXHR, textStatus, err) { 
    console.log('Error on web service call: ' + err + ' Text Status: ' + textStatus + ' Message: ' + jqXHR.responseXML); 
  }); 
} 

function onQueryFailed(sender, args) { 
  console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); 
}

3. Verify SharePoint Column Internal Names

Double-check that the names in fieldMap match the internal names of your SharePoint columns. Display names may have spaces or special characters, but internal names are simplified (e.g., "Street Light Attached" becomes "StreetLightAttached"). Find internal names by going to List Settings > Column > check the URL for the Field parameter.

Final Checks

  • Test with a small set of problematic records (EPOCH >1523302307) to confirm the field mapping fixes the "column does not exist" error
  • If importing thousands of records, split batches into 100-200 items to avoid hitting SharePoint’s list view threshold

内容的提问来源于stack exchange,提问作者Zach

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:03:04