0

How to get the deleted file when itemDeleted event fire in remote event receiver in SharePoint Online.

I have tried as follows but this does not work:

List photos = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
ListItem item = photos.GetItemById(properties.ItemEventProperties.ListItemId);
string filename = Convert.ToString(item["FileLeafRef"]);
1

Use ItemDeleting event instead of ItemDeleted if you want to get the file which is to be deleted. For ItemDeleted event List Item properties are not available.

SharePointEventReceiver

1

ItemDeleted Event will trigger after the file has been deleted, if you want to get file which will be deleted, use ItemDeleting instead:

SharePoint Remote Event Receiver – Item Deleting – Using Provider hosted App

0

You can get deleted item as follows.

  var fileurl = properties.ItemEventProperties.BeforeUrl;
    string[] nFileName = fileurl.Split('/');
    var fileName = nFileName[1]; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.