Today I had a look at the SharePoint connector in Power automate and there are two when a file and when an item is deleted triggers.

When a file is deleted

In this post I’m going to have a look at the “When a file is deleted” trigger.

When a file is deleted trigger

Then when you look at the information available after this action within the dynamic content, it is easy to find out which file was deleted and who deleted the file. It is even possible to find out when it was deleted.

When a file is deleted properties in dynamic content

Although it isn’t possible to undelete the file or to get to the content of the file at least you can now trigger  process that you would like to start on deletion of a document.

When a file or item is deleted triggers in Power Automate Microsoft Office 365, Microsoft Flow objectvariable1

Both of these  Dynamic content options give you the data you would expect. Also note that the ID of the document is given! This ID can also be retrieved then you use a variable of the type Integer

When a file or item is deleted triggers in Power Automate Microsoft Office 365, Microsoft Flow iddata
When a file or item is deleted triggers in Power Automate Microsoft Office 365, Microsoft Flow outputitemsdeleted

Looking at the name of the dynamic content “List of Deleted items”, I would have expected that deleting multiple documents would only trigger one flow. This however is not the case. When you delete multiple documents you only get one document listed in each flow and multiple flows will be started.

Deleted By username displays the user’s display name rather than their user login. I’m not sure if this could cause problems, but it is at least something to be aware of.

Then I tried deleting folders and this trigger even handles the deletion of folders within your library. in short this looks like a nice improvement to the Flow offerings.

But this is not all! There is also a trigger for the deletion of items:

When an item is deleted trigger

Other than handling items rather than handling files in libraries there is no real difference.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

20 thoughts on “When a file or item is deleted triggers in Power Automate”
  1. Hello, great article!

    Upon delete of an item in the SharePoint calendar I want this item also deleted from the users calendar via Microsoft Flow. I followed this guide to create a Flow to have the item added or modified, which works great:

    hxxps://powerusers.microsoft.com/t5/Building-Flows/SharePoint-Calendar-and-Events/m-p/121418#M11799

    But now I want to also create a Flow to delete an item if it’s deleted from SharePoint.

    I found the “When an item is deleted” action but I’m stuck, the Get Item action can’t be used because the item is already deleted.

    Please assist, it will be greatly appreciated!

    1. “But now I want to also create a Flow to delete an item if it’s deleted from SharePoint.”

      And here I mean:

      But now I want to also create a Flow to delete a calendar item from the users calendar if it’s deleted from a SharePoint Calendar.

    2. Hi Andries,

      All the deleted item trigger gives to you is:

      {
      "ID": 10,
      "Name": "test",
      "FileNameWithExtension": "test",
      "DeletedByUserName": "Pieter Veenstra",
      "TimeDeleted": "2018-06-04T12:34:31Z",
      "IsFolder": false
      }

      And indeed it is not possible to get to the data of the deleted item. Therefore the only way you could identify the calendar item would be by storing the ID and Name in the calendar item somewhere.

      You could probably use the above information tho get to your deleted item in the recycle bin. I will create a post for this shortly.

      1. Thank you for your quick reply! I do have a custom column in SharePoint named “outlook event id”, Outlook fill this field. ( see hxxps://powerusers.microsoft.com/t5/Building-Flows/SharePoint-Calendar-and-Events/m-p/121418#M11799) However I don’t seem to be able to use this field when using the “When an item is deleted” action?

      2. Hi, very nice write up. Have you found a way to access the recycle bin with Flow? I’d like to get some more properties from the deleted file.

      3. You can get to the recycle bin through the rest API ( /_api/web/RecycleBin ), however that isn’t going to give you any of the metadata that originally belonged to the document.

  2. Thanks for you analysis of the delete trigger. I wanted to use that trigger to notificate the creator of an item, that its item was deleted, in case someone else did it or he/she per accident.
    Unfortunately “get item” does not work anymore, once the item is deleted (surprise!) and I did not find a way to inform the person who created the item.

    Have you found out something?

  3. Are there any special requirements needed to get this trigger to return values? I’ve built a flow and pointed it at a SharePoint calendar with just a basic email out. The trigger does start when I delete a calendar item, but the flow sends empty values for all fields except for ID (Deleted By, Filename with Extension, and Name are all EMPTY).

    I tried turning on versioning for the calendar, but that did not help.

  4. I have used when file is deleted but in body out put Name, FileNameWithExtension
    and DeletedByUserName are showing blank
    {
    “ID”: 44394,
    “Name”: “”,
    “FileNameWithExtension”: “”,
    “DeletedByUserName”: “”,
    “TimeDeleted”: “2019-07-17T08:49:03Z”,
    “IsFolder”: false
    }

  5. Hi,

    Very good flow, i am looking to achieve somthing very similar but with a monthly report of what files have been deleted over the last month, is this somthing possible with this or would it be a completely different flow?

Leave a Reply to AndriesCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading