Bulk Delete The SharePoint List Items Using Power Automate Flow

Introduction

In this blog, we will learn how to quickly build a Power Automate flow to bulk delete the SharePoint list items. We can always use a PowerShell or REST API to perform these kinds of operations. But in some cases, these approaches might not work. In such cases, we can quickly build a power automate flow to delete multiple list items. Let us see step by step tutorial.

Flow to bulk delete the SharePoint list items

I have a SharePoint list with more than 5000 items.

Step 1 - Create an instant flow

We will create an instant flow which we will trigger manually.

Step 2 - Initialize a variable

In the next steps, we will use the Get Items action to get the SharePoint list items. We know that it will fetch a maximum of 5000 items at a time. So we will use the do until loop on Get items to get more than 5000 records.

Initialize an integer variable with the value as 0. We will use this variable to iterate the do until loop to perform the delete operation on all items.

Step 3 - Add a Do until Loop

We will use this loop to iterate multiple times to get all SharePoint list items. The Do until loop will run until the variable that we have defined in the previous step exceeds the total number of records in the list. Here my list has 6001 items. Also, change the limit to 5000.

Step 4 - Add Get items action

Now add Get items action inside the do until loop. Provide the site address and list name. Add the Top count parameter as 5000. You can keep this as 500 or 1000 also in case you face any time out issues at a later point.

Step 5 - Add Delete item action

Add a Delete Item action below the Get items action inside your do until loop. Provide the site address and list name. In the Id field, choose the ID from Output of Get Items action as shown below.

It will automatically add a Apply to each loop to your delete action. Your Apply to each loop should look like as below:

Step 6 - Increment the variable

This is the final step where we need to increment the variable by 5000. You should use the same value which you have used in Step 4 (top count).

Your flow should look as below

I hope you have liked this article. If you have any queries, feel free to ask in the comment section below.