Home > CMS- Content Management System > Sharepoint > How To Update And Delete Items in Bulks Using PnP In SPFx

How To Update And Delete Items in Bulks Using PnP In SPFx

This post was most recently updated on July 29th, 2024

in this blog, we cover the PnP Bulk Update and Delete Items.

Brief information about SP-PnP-JS

PnPJS is an open-source solution with active community providing support for it. There is no SLA for the open-source tool support from Microsoft.

SP PnP JS are patterns and practices that the core JavaScript library offers. They are simplified common operations with SharePoint to help developers concentrate on business logic without worrying much about the underlying technical implementation. It contains fluent APIs to work with SharePoint REST APIs.

Getting Started

Install the library and required dependencies

This approach avoids multiple calls for the same list’s entity type name.

I have created id’s array and passing id’s to inBatch operation with PnP update method in loop, also we capturing the error in catch block.

Limitations : We can not update more then 1000+ items at a time, it will throws this error message

“The current change set contains too many operations. A maximum number of ‘1000’ operations are allowed in a change set.”

I recommended to update items in chunks to make process fast and avoid error.

Delete items in bulk

There is two approach either we can delete items permanently or we can move to recycle bin.

I have created id’s array and passing id’s to inBatch operation with PnP recycle method in loop, also we capturing the error in catch block.

Getting and Deleting a collection using filter

In this method we are getting deleting id’s by passing id to filter method. This method helps to delete items which are lookup in another list. if one list has reference on another list. 

Limitations : We can not update more then 1000+ items at a time, it will throws this error message

“The current change set contains too many operations. A maximum number of ‘1000’ operations are allowed in a change set.”

I recommended to update items in chunks to make process fast and avoid error.

Hope you find it helpful. If you liked this article, then please share and comment.

Resources:

This Article is TAGGED in , , , , , , , . BOOKMARK THE permalink.

Avatar photo
Chintan Upadhayay
I am a senior web developer with more than 4+ years experience in WordPress, PHP, MySQL, HTML, CSS, jQuery and other web technologies. I am the beginner in SharePoint and Learning SharePoint.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">