Skip to content

Instantly share code, notes, and snippets.

@ashelopukho
Last active November 19, 2018 09:24
Show Gist options
  • Save ashelopukho/47efec9d05135a7a969e11b397059ff5 to your computer and use it in GitHub Desktop.
Save ashelopukho/47efec9d05135a7a969e11b397059ff5 to your computer and use it in GitHub Desktop.
Update multiple items: pnp js
(async () => {
const batch = pnp.sp.web.createBatch();
const list = pnp.sp.web.lists.getByTitle('ListA');
const items = await list.items.select('Id,Title').get();
const entityTypeFullName = await list.getListItemEntityTypeFullName();
for (const item of items) {
list.items.getById(item.Id).inBatch(batch)
.update({ Title: `${item.Title} (${item.Id})` }, '*', entityTypeFullName);
}
await batch.execute();
console.log('Done');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment