Inform authors when a document is deleted from SharePoint with Microsoft Flow

In my post about the When a file is deleted trigger in Microsoft Flow I described the trigger that will fire when a document is deleted.

The trigger however will be quite useless if you want to do anything as there isn’t much information available within the information returned. One of my followers asked todayon the post mentioned above if it was possible to email the author when someone deletes document.

Deleted File

But no need to panic!

As so often the Send an HTTP  request to SharePoint action will come to the rescue.Get Reycle bin content with HTTP request using the REST API

The /api/web/RecycleBin REST API will give you all the documents that were deleted.

Then you can add a filter so that only the documents with the same file name are returned. In a similar way you could also include the Time deleted as a filter. But I would like to keep the example in this post simple.Send Email For Deleted File

To get the email address for the author’s email address the following expression will get the job done:

first(body('Send_an_HTTP_request_to_SharePoint')?['d']?['results'])['AuthorEmail']
Advertisements

2 thoughts on “Inform authors when a document is deleted from SharePoint with Microsoft Flow

  1. Thank you very much for your prompt help!
    I got both issues, language issues (that’s why I was not searching the net for “author”) and reading codes: Could you explain the last part of your formula: first(body(‘HTTP-Anforderung_an_SharePoint_senden’)?[‘d’]?[‘results’])[‘AuthorEmail’]
    I do not get the authorEmail, Flow tells me, that the value AuthorEmail can not be selected. I have tried that with “Author”, as this is the column’s name, but this does not work either.

    Like

    1. Hi Johannes,

      Can you email the output from the HTTP request action to contact@veenstra.me.uk? Most likely, there is something not right there.
      In my case I get the following:

      {
      "d": {
      "results": [
      {
      "__metadata": {
      "id": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'582be79c-57a1-4d2c-bdc0-cecdc3e00a71')",
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'582be79c-57a1-4d2c-bdc0-cecdc3e00a71')",
      "type": "SP.RecycleBinItem"
      },
      "Author": {
      "__deferred": {
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'582be79c-57a1-4d2c-bdc0-cecdc3e00a71')/Author"
      }
      },
      "DeletedBy": {
      "__deferred": {
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'582be79c-57a1-4d2c-bdc0-cecdc3e00a71')/DeletedBy"
      }
      },
      "AuthorEmail": "pieter@PieterVeenstraMVP.onmicrosoft.com",
      "AuthorName": "Pieter Veenstra",
      "DeletedByEmail": "pieter@PieterVeenstraMVP.onmicrosoft.com",
      "DeletedByName": "Pieter Veenstra",
      "DeletedDate": "2019-05-08T15:54:35Z",
      "DeletedDateLocalFormatted": "08/05/2019 16:54",
      "DirName": "Shared Documents",
      "DirNamePath": {
      "__metadata": {
      "type": "SP.ResourcePath"
      },
      "DecodedUrl": "Shared Documents"
      },
      "Id": "582be79c-57a1-4d2c-bdc0-cecdc3e00a71",
      "ItemState": 1,
      "ItemType": 1,
      "LeafName": "Document.docx",
      "LeafNamePath": {
      "__metadata": {
      "type": "SP.ResourcePath"
      },
      "DecodedUrl": "Document.docx"
      },
      "Size": "127810",
      "Title": "Document.docx"
      },
      {
      "__metadata": {
      "id": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'325a1cee-99fd-4ff3-9538-c7ad66166c55')",
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'325a1cee-99fd-4ff3-9538-c7ad66166c55')",
      "type": "SP.RecycleBinItem"
      },
      "Author": {
      "__deferred": {
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'325a1cee-99fd-4ff3-9538-c7ad66166c55')/Author"
      }
      },
      "DeletedBy": {
      "__deferred": {
      "uri": "https://pieterveenstramvp.sharepoint.com/_api/Web/RecycleBin(guid'325a1cee-99fd-4ff3-9538-c7ad66166c55')/DeletedBy"
      }
      },
      "AuthorEmail": "testuser@PieterVeenstraMVP.onmicrosoft.com",
      "AuthorName": "Test User",
      "DeletedByEmail": "pieter@PieterVeenstraMVP.onmicrosoft.com",
      "DeletedByName": "Pieter Veenstra",
      "DeletedDate": "2019-07-01T09:41:20Z",
      "DeletedDateLocalFormatted": "01/07/2019 10:41",
      "DirName": "Shared Documents",
      "DirNamePath": {
      "__metadata": {
      "type": "SP.ResourcePath"
      },
      "DecodedUrl": "Shared Documents"
      },
      "Id": "325a1cee-99fd-4ff3-9538-c7ad66166c55",
      "ItemState": 1,
      "ItemType": 1,
      "LeafName": "Document.docx",
      "LeafNamePath": {
      "__metadata": {
      "type": "SP.ResourcePath"
      },
      "DecodedUrl": "Document.docx"
      },
      "Size": "55640",
      "Title": "Document.docx"
      }
      ]
      }
      }

      Like

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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