I am trying to add 5000 items in a SharePoint list using JSOM. But unfortunately didn't get any luck.
function createListItem() {
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('DummyList');
var itemCreateInfo = new SP.ListItemCreationInformation();
for(var i = 0;i<5000;i++)
{
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('ItemNumber', i);
oListItem.update();
}
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
console.log('Item created: ' + oListItem.get_id());
}
function onQueryFailed(sender, args) {
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
But after some time server stops responding. I know there is something called Threshold limit. But according to the requirement more than 5000 items should be stored in one take only. I have no idea where I am making mistake. Please help.