Question

I was wondering if there was a good way to monitor a document library on SharePoint for changes (new files added, files changed / checked-in, files deleted, etc.)

Basically, what System.IO.FileSystemWatcher does on local / network directories.

Are there events that get fired when documents are uploaded to document libraries?

Perhaps creating a workflow on the document library that fires onCreate / onModify would be better?

Any suggestions are welcome.

Was it helpful?

Solution

Take a look at event receivers for lists/document libraries. There are both synchronous and asynchronous options built into the object model. (ItemAdded, ItemAdding, ItemUpdated, ItemUpdating ... and so on.)

The following site should give you a good start: http://www.davehunter.co.uk/Blog/Lists/Posts/Post.aspx?List=f0e16a1a%2D6fa9%2D4130%2Dbcab%2Dbaeb97ccc4ff&ID=69

OTHER TIPS

That depends whether you need to react to these events immediately or if you can gather them later. For immediate actions event receivers would be the best option but you have to prepare them for each action type you want to handle. For the latter, you can use audit log. That's a feature in sharepoint, that gathers information about user actions. This will require enabling some features on sites and maybe some configuration where you can specify which actions should be logged).

View: https://support.office.com/en-us/article/view-audit-log-reports-b37c5869-1b47-4a82-a30d-ea20070fe527 Configure: https://support.office.com/en-us/article/configure-audit-settings-for-a-site-collection-a9920c97-38c0-44f2-8bcb-4cf1e2ae22d2

Unfortunately I'm not sure if it's possible to get this data using CSOM - according to answer from the link below, you'll have to use server solution: https://social.msdn.microsoft.com/Forums/office/en-US/fd628034-9d6d-4f98-afb8-1d0bd6926bd0/accessing-audit-logs-using-csom-in-sharepoint-2013?forum=sharepointdevelopment

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top