tags:

views:

189

answers:

2

Hi

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 ?

+1  A: 

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.

Lars Fastrup
So according to this I have to create a timer job that queries the log and insert data to external storage (e.g. list) that I can filter by in my web part. This could be performance heavy because I'm want to show this info for each user.
armannvg
Yes, I would also use a timer job. Also, you are right that the performance impact can be significant if you have many users and each should have their own set of last accessed documents. But how about maintaining a list of accessed documents within the last 7 days or so and include the user name as a column? Then you can query by user and sort descending by access date.
Lars Fastrup
+1  A: 

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.

Magnus Johansson