2

We are using SharePoint online 2013. In our project we have one document library and one list view. We want to create list item whenever any document is added, updated or deleted from the document library. We are able to create and update list item on create and update document in document library. But we are not able to track item deleted. Any idea how can we do that?

0

You may create an item event receiver (example) for 'item deleted' event. And create the list item in the code of the event handler .

Visual Studio walk-through how to create a feature with the handler like this.

  • Thanks for your reply Burst. I will try this and let you if it works or not. – Sami Mar 26 '17 at 20:15
0

You can write an Event Receiver (Feature).

Make sure that the ListTemplateId in the Elements.xml of the Listener is 101. This means, that it will only listen for Document Librarys.

In Addition to this be sure which Scope you will use for the Feature (Site, Web, etc).

The Listener will receive ALL events for all document librarys in the scope where the feature is activated but you can check if the WebURL and ListTitle is the one to observe.

The following is how to override the Receiver Events:

public override void ItemDeleting(SPItemEventProperties properties) {

// Use properties.ListTitle or properties.WebURL to check if it is the correct library

// get context

SPSite siteCtx = properties.OpenSite();

}

I hope it helps.

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.