Bí quyết Hướng dẫn SharePoint delete list items older than Mới Nhất
Quý quý khách đang tìm kiếm từ khóa SharePoint delete list items older than 2022-01-10 07:38:02 san sẻ Bí kíp Hướng dẫn trong nội dung bài viết một cách Mới Nhất.
The standard actions in Power Automate make it simple to perform CRUD operations against a SharePoint list. But they are designed to be easy to use and do not focus on performance. This post will explain how to delete many items from a SharePoint list using the $batch API.
Table of contents
The standard Power Automate method
The SharePoint Batch Method
Flow Detail
Flow Code and Implementation
Video tương quan
Warning!!
This post is all about deleting SharePoint data, Please take care when replicating this flow!
Table of contents
The standard Power Automate method
The SharePoint Batch Method
Flow Detail
Flow Code and Implementation
Conclusion
The standard Power Automate method
A flow to delete items from a SharePoint list is very simple to create and might look something like this:
This flow will work fine, and on a small list it would be perfect, but it has a number of problems:
If the list contains more than 5,000 items, the Get Items action will have to be placed in a loop.
It will consume a lot of API actions and may cause you to exceed your daily limit.
It is very slow.
This flow took four minutes to complete on a small list containing only 500 items.
A few people from my YouTube Channel and others that have commented on the method I used to get more than 5,000 items from a SharePoint list have been looking for a faster and more efficient method.
The SharePoint Batch Method
It is possible to make batch requests of actions for SharePoint to execute using the OData $batch query option. There are many applications for this method.
Because of the increased complexity of this flow, I suggest that you would only use it if you want to speed up the process of deleting items or reduce the number of API actions that you are using.
This flow took 47 seconds to complete on the same list containing 500 items.
To build this flow I used the excellent documentation about the batch method from this website. The batch is a request to the SharePoint API that is formatted in a particular way. Here is an example request which would delete two items:
The API is quite fussy and if the request is not delivered in exactly the expected format it will fail.
Flow Detail
I have created a flow which, hopefully removes most of the complication associated with this method, which you can copy and paste into your environment. Here is a screenshot of the flow:
The Flow follows this process:
Creates a variable used to hold the number of items found.
A compose action defines the settings for the remainder of the flow.
The site address
The list name
Another compose action creates a template for the change sets.
A Do Until loop is started and continues until there are no items left.
Get Items collects the list items in batches of 1,000 items (this is the limit for a batch)
A select action creates the change set for each item.
A compose action joins the change set.
Finally a SharePoint HTTP action performs the request.
Flow Code and Implementation
To implement this flow, do the following:
Create a new flow
Add an Initialize variable action and name the variable itemCount.
Copy and paste the Scope code below into your flow.
Modify the settings action to create the correct values for your environment.
Optional Step. Add an OData File to the Get Items action to narrow the selection of items to be deleted. Check out this excellent OData Cheat Sheet by Tom Riha for help with that.
Here is the code for the scope, which performs does the deletions.
If you need to delete many items from a list in an efficient manner this flow should improve your performance and reduce the number of API actions that your flow consumes. I hope you are able to implement it into your environment easily. Please drop me a question in the comments if you need further help.
Video tương quan
Review SharePoint delete list items older than ?
Một số hướng dẫn một cách rõ ràng hơn về đoạn Clip SharePoint delete list items older than tiên tiến và phát triển nhất .
ShareLink Tải SharePoint delete list items older than miễn phí
Bạn đang tìm một số trong những Chia SẻLink Tải SharePoint delete list items older than Free.