Do you want to delete all the items in your SharePoint list using Power Automate?
SharePoint lists are a great tool for storing and tracking things such as tasks, clients, contacts, or other important business data. They are very flexible and can be accessed from anywhere to support real-time collaboration.
There are many reasons why you might need to delete all the items in your SharePoint list. Perhaps the data is no longer relevant, maybe it is only a test list with test data, or you want to start fresh with new information.
Whatever the case. this can be done easily with Power Automate. For example, you can set up a flow to remove all the items from your SharePoint list on a monthly schedule.
This post will show you how to set up a flow to delete all the items in your list.
Set the Trigger
Deleting all the items in your list could be a small part of a bigger flow initiated by just any trigger.
This example will set up a flow to delete the items based on a schedule that runs each month.
- Go to the Create menu.
- Select Scheduled cloud flow.
- Enter a Flow name in the Build a scheduled cloud flow menu.
- Set the Starting date and time. This will be the same date and time each month.
- Set Repeat every field to 1 and Month.
- Press the Create button
This will create a new flow that is scheduled to run once a month and you will be able to add the actions needed to delete your SharePoint items.
Get All Items from the SharePoint List
In order to delete all the items in your SharePoint list, you will first need to list them all.
This will get you an array of item IDs which can then be used to delete the items.
- Add the Get items action from the SharePoint connector to your flow.
- Select the Site Address that contains the list.
- Select the List Name of the items to be deleted.
You will want to list the maximum number of items possible since the goal is to delete all the items. Unfortunately, this action can return at most 5,000 of your list items at a time.
The default number of items returned is set to 100, so you will need to adjust this to the 5,000 maximum.
- Click on the Ellipse icon in the top right of the Get items action.
- Select the Settings option.
- Turn on Pagination and set the Threshold to 5000.
- Press the Done button at the bottom of the settings.
Now you will be able to get 5000 items in each flow run.
Delete Items from the SharePoint List
Now you can add the action to the flow to delete the items from the Get items action.
- Add the Delete item action from the SharePoint connector.
- Set the Site Address to the same as the Get items action.
- Set the List Name to the same as the Get items action.
- Add the ID dynamic content from the Get items action to the Id field of the Delete item action.
📝 Note: This will automatically add an Apply to each action to the flow which will allow the flow to loop through all the items in the list and delete them.
Add Concurrency to Speed Up the Flow
The Apply to each action will only delete one item from your list at a time.
This can mean the flow will take a long time to run if you have a lot of items on the list. But there is a way to speed up the flow quite considerably.
- Click on the Ellipse icon in the Apply to each action.
- Go to the Settings option.
- Turn on the Concurrency Control.
- Set the Degree of Parallelism to the maximum value of 50.
- Click on the Done button.
Now the flow will delete items from the SharePoint list in batches of 50 items. This should speed up the total run time of the flow!
Conclusions
SharePoint lists are a great tool and they are even better when used with the automation available in Microsoft Power Automate.
Deleting items in a list could be a tedious task if you need to repeat this every month. But Power Automate can do all the work for you with a small bit of setup.
Have you ever needed to delete all the items in your SharePoint list? Did you use a Power Automate flow to get it done? Let me know in the comments!
Yes, I have got this use case to delete the records having more than 4K records.
As you mentioned, it’s a very tedious job to delete the records either manually or via Power automate.
Even with the concurrency set to 50, deleting 4K records is very time consuming.
Other way around would be to delete the list altogether ( if you are deleting the whole set of records from the list) and recreate it. Here, atleast we are saving the time consumed by the delete operation.
Is there any other work around?
Yes, creating a new list is another option.