Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

Delete document also from Recycle bin with Power Automate

Posted on January 8, 2023January 8, 2023 by Tom

“Can I restrict users from restoring deleted files from the recycle bin, to delete them also from there within Power Automate flow?”


If you use SharePoint as a document management system, you get a lot of functionality out of the box. Files are versioned, there’s support for draft/published versions, and nothing is deleted permanently. And that’s great in many situations. But in some specific situations it’s not beneficial, more specifically if you delete files using a flow and users keep restoring them from the recycle bin.

How do you fully delete a file to avoid it?

Delete file from a recycle bin with an HTTP request

As Power Automate doesn’t have any action related to the SharePoint recycle bin, you must use a “workaround”. That means another HTTP requests, or two…

To delete a file from a recycle bin you need the file ID. Not the file name, not the identifier, but the unique id in the recycle bin. This id will be among the outputs of the HTTP request below…

Method:
GET

Uri:
_api/web/RecycleBin?$filter=LeafName eq '<fileNameWithExtension>'&$select=Id

…and you can access it directly with this expression:

body('Send_an_HTTP_request_to_SharePoint')?['d']?['results'][0]?['Id']

Once you have the id you can do the actual removal from the recycle bin.

Method:
DELETE

Uri:
_api/web/RecycleBin('<fileUniqueId>')
Power Automate delete recycle bin

That’s it, the file is completely gone.

Summary

Recycle bin is another part of SharePoint that doesn’t have a direct support from Power Automate, yet if you delete any file it’ll always end there. If you want to remove it also from the recycle bin, you’ll need two HTTP requests – one to get the file ID and another one to delete the file. Just be careful with the solution as it’s bypassing one of the safety SharePoint features. Once you delete the file it’ll be deleted completely.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

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

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes