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.
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.
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.
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
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:
Other than handling items rather than handling files in libraries there is no real difference.
Great to know it! This is something that I missed several times!
Indeed! The flow team have made some major improvements yesterday! The HTTP request action is another one of those other important changes.
https://veenstra.me.uk/2018/05/02/microsoft-flow-create-a-new-sub-site-using-microsoft-flow/
[…] Recently a new set of triggers was added to the Microsoft Flow SharePoint connector as I described in When a file or item is deleted triggers post. […]
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!
“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.
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.
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?
Hi Andries,
I don’t think that there is an API to get to the custom properties of the deleted items in a recycle bin.
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.
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.
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?
Hi Johannes,
In the below post you will find the solution:
https://veenstra.me.uk/2019/07/01/inform-authors-when-a-document-is-deleted-from-sharepoint-with-microsoft-flow/
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.
Hi Casey you might want to have a look at one of my more recent posts:
https://veenstra.me.uk/2019/07/01/inform-authors-when-a-document-is-deleted-from-sharepoint-with-microsoft-flow/
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
}
Hi Anuj,
Some of the data returned was recently removed.
You can use a rest api call as described in this post to get the rest of the details:
Inform authors when a document is deleted from SharePoint with Microsoft Flow
Awesome post Pieter. This is just what i needed 🙂 Have a great day
Thank you!
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?
I would probably schedule a flow on a monthly basis rather than an on when a file is deleted trigger.