When we want to fix something quickly then using SP Editor chrome extension gives an oppotunity to run JS script from your browser in Developer Tool.
paste the following script to add items to SharePoint list using batching and hit CTRL+D to run the script
import { sp } from "@pnp/sp/presets/all"; (async () => { console.clear(); let list = sp.web.lists.getByTitle("Large"); const entityTypeFullName = await list.getListItemEntityTypeFullName(); let batch = sp.web.createBatch(); const totalItems = 6000; for (var i = 1; i < totalItems; i++) { console.log(`Adding Batching for Item ${i}`); list.items.inBatch(batch).add({ Title: `Item ${i}` }, entityTypeFullName); if(i % 100 === 0) { console.log(`Executing Batch for 100 Items`); await batch.execute(); batch = sp.web.createBatch(); } } })().catch(console.log)
In the console window you can see the item being added using batching.
Happy Coding
Fazil
Leave a comment