Thank you for choosing Microsoft Community.
You can definitely streamline your process to handle large datasets more efficiently.
Here’s a step-by-step guide to create a flow that deletes all items in a SharePoint list and updates it with new data from your daily email attachment:
Trigger: Use the "When a new email arrives" trigger in Power Automate to start the flow when you receive the email with the Excel attachment.
Get Attachment: Use the "Get attachment" action to retrieve the Excel file from the email.
Delete Existing Items:
Use the "Get items" action to retrieve all items from the SharePoint list.
Add an "Apply to each" loop to iterate through the items.
Inside the loop, use the "Delete item" action to delete each item. For large lists, consider using the SharePoint Batch API for better performance.
Read Excel Data:
Use the "List rows present in a table" action to read the data from the Excel file. Ensure your Excel file has a table defined.
Add New Items:
Add another "Apply to each" loop to iterate through the rows of the Excel table.
Inside the loop, use the "Create item" action to add each row to the SharePoint list.
Here’s a more detailed breakdown:
Trigger:
Use "When a new email arrives" (V3) trigger.
Set the filter to only trigger on emails with the specific subject or from a specific sender.
Get Attachment:
Use "Get attachment" (V2) action.
Specify the message ID and attachment ID from the trigger.
Delete Existing Items:
Use "Get items" action to retrieve all items from the SharePoint list.
Add an "Apply to each" loop to iterate through the items.
Inside the loop, use the "Delete item" action to delete each item.
For large lists, consider using the SharePoint Batch API for better performance.
Read Excel Data:
Use "List rows present in a table" action to read the data from the Excel file.
Ensure your Excel file has a table defined.
Add New Items:
Add another "Apply to each" loop to iterate through the rows of the Excel table.
Inside the loop, use the "Create item" action to add each row to the SharePoint list.
This approach should help you efficiently delete and update your SharePoint list with new data daily. If you need more detailed steps or run into any issues, feel free to ask!
If this Post helped you, please click "Does this answer your question" and like this post to help others in the community find the answer too!
Happy to help
Robu 1