web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / File deletion approval...
Power Automate
Unanswered

File deletion approval flow - Sharepoint

(0) ShareShare
ReportReport
Posted on by 16

Hello,

I'm trying to create an approval process when someone tries to delete a file.

So I want this: When user hit delete -> The file stays, column "Deletion Status" changes to "Pending" -> Email sent to the approver -> and so on.

Currently, I'm doing it like this:
When file is deleted -> change "Deletion Status" to "Pending" -> revive the file from RecycleBin (with GET and POST http request) -> send notification to the approver -> when the approver hits "approve", delete the file.

After the last step, another flow is triggered since that file is deleted, hence an infinite loop.

 

Am I over-complicating this, or how can this process be done correctly?

Thank you in advance.

Categories:
I have the same question (1)
  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @TechTing ,

     

    Since the trigger of "When a file is deleted" is the reactive to a successful file deletion and there is no Out-of-Box method to intercept and override delete commands, I think your idea of restoring the file from Recycle Bin is excellent. 

    I also come up another thought to achieve your needs, by taking advantage of the SharePoint Column Formatting functionality to launch a flow by button on the list. For more details, please follows this blog.

    When clicking the Delete button on the list, a flow will be triggered to send a approval to Users, and delete the file if approved. 
    Create a flow triggered 'For a Selected File' like below, then customize the SharePoint column mentioned in above blog, replace the GUID of flow in 'actionParams' section.

    Note: the flow must be created in Default Environment.

    Snipaste_2020-12-09_13-58-44.pngSnipaste_2020-12-09_13-56-13.png

     

    Hope this helps.

    Sik

  • TechTing Profile Picture
    16 on at

    Hello Sik,

    Thanks very much for your help. I'll try this out. 

    Regarding my method, is there any way I can retrieve the file's metadata when it's in the recyclebin? For example, The file only get deleted if the "Deletion Status" column says "Pending" so it will not fall into an infinite loop again. I also tried using the Title column, but it seems like it is the file's name itself, not the real "title". 

    As you can see here, when the file gets the permission to be deleted, I change the Title to "Approved"

    TechTing_1-1607502735129.png

     

     

  • v-siky-msft Profile Picture
    on at

    Hi @TechTing ,


    Unfortunately, from the output of Trigger and 'Get' HTTP request action, we can found that only a very limited number of properties can be returned, but the metadata for the files is not included. For now, as far as know, there is no method to retrieve metadata for the deleted file in recycle bin of SharePoint site.

    Perhaps consider adjusting the logic order of your flow? First send the approval and then restore the file if Approved. The downside is that file is always in the recycle bin while waiting for the approval.

    Sik

     

  • TechTing Profile Picture
    16 on at

    Hello @v-siky-msft

    Thanks for your promt reply. That I have already thought of but my boss doesn't want that.

    Your solution seems to be the most viable option right now. Thanks alot for your help.

    Also, can I set users' permission to not delete the file? (Only the approvers can delete file); however, such user cannot rename or move file, as I read from some articles, right?

  • v-siky-msft Profile Picture
    on at

    Hi @TechTing ,

     

    Yes, and add more:

    restrict User's Delete Permission and force them delete the file by my method. In the flow, grant the Delete permission by HTTP request temporarily to delete the file and remove the Delete permission again at last.

    Sik

  • TechTing Profile Picture
    16 on at

    Hello @v-siky-msft,

    I'm deploying your method. Is there anyway that, when the user click delete, the flow runs automatically without the user having to click "Continue" to run the flow?

    TechTing_0-1607510703832.png

     

  • v-siky-msft Profile Picture
    on at

    Hi @TechTing ,

    This is a by design behavior to validate the authentication for connection, I'm afraid there is no way to bypass this. 

    Please vote for this idea as your needs.

    Sik

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard