2
votes

I've been asked to create a web part in Sharepoint that lists up the last 10 documents the user has accessed in a Site collection.

My client wants a quick way for users to access documents so that they won't have to dig through a folder structure to find a document, since users most of the time access the same document over and over again.

The problem is that i'm not sure if it's possible since I can't seem to find any property on SPListItem, SPItem or SPFile that can help me out with this task. Has anyone done anything similar or know about any solution that can help me verify that this is possible ?

2

2 Answers

1
votes

This information is not readily available on file and item objects in SharePoint. They can only tell you the creation date and the last modified date.

But one option could be to turn on the audit log for the site collection and query that. But pay attention to performance as the audit log can grow large, making real-time queries across all data very slow. Best to create a background job that frequently queries the audit log for new entries and updating a list of documents last accessed.

1
votes

A suggestion is to develop a HTTP module that intercepts each document download. Store the information in a custom list, with document ID and username. (And maybe more meta data such as site collection name, site name, list name and so on)

Provide a mechanism in the custom list that only saves the last 10 items.

Add a content query web part to your page that queries the custom list based on user name and shows the items, i.e. the 10 last accessed documents.