Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to capture the View document "event" of when a user clicks on a document in a document library and it opens up the document in Word or Excel...

There is not such an event receiver and using ItemUpdated or ItemUpdating wouldn't work since those are only triggered when a user edits the properties of that document.

I know there is an audit log which I can access via the object model to get the view count, but the idea is to have a "View Count" column in that document library that displays how many times that document has been viewed or opened. If i use the audit log's view count, I would have to implement some type of timer job that would periodically poll the log and update the "View Count" column.

How do I capture the event when a user opens a document in a document library?

share|improve this question

1 Answer 1

As you've found, there is no such event. In my opinion you've described the best solution - a timer job that periodically queries the audit log and updates the "View Count" column.

Another option is to use an HTTP module to capture the request.

share|improve this answer
    
I wouldn't say the 'only way' as you can always go down the HTTPModule route, but you have to be very careful when you do that (plus it will be messy) –  Muhimbi Jun 15 '11 at 5:54
    
@Muhimbi: Do you know if HTTPModules are supported in SP2010? –  AlexPoint Jun 15 '11 at 6:40
    
HTTPModules are supported in SP2010, and in my experience work better than on SP2007 when capturing streams, although you don't need that for your scenario. Just be very careful when calling into the SP object model as every request goes through he module, resulting in scalability problems if you are not careful. –  Muhimbi Jun 15 '11 at 7:57
    
@Muhimbi Good pick up, thanks! I hadn't thought of that and have added it to my answer. Please add another answer if you can give more details on that. –  Alex Angas Jun 15 '11 at 9:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.