Pergunta

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"]);
Foi útil?

Solução

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

Outras dicas

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

You can get deleted item as follows.

  var fileurl = properties.ItemEventProperties.BeforeUrl;
    string[] nFileName = fileurl.Split('/');
    var fileName = nFileName[1]; 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top