Answered Display Last Viewed or Last Accessed date in a View

  • Thursday, May 03, 2012 3:16 PM
     
     
    I understand enabling Auditing at a Content Type or Document Library level allows you to run reports to determine when documents are opened or downloaded (last viewed). Is there a way to show this "last viewed" date in a View? For example, I want to create a View that shows documents who have not been viewed in over 1 year.  This is SharePoint 2010.  If this is not possible OOB - can it be achieved using SharePoint Object Model?  Though, the preferred is OOB.

All Replies

  • Thursday, May 03, 2012 3:40 PM
     
     
    I am afraid there is no OOB support for this ( to put the last viewed data in audit report into item as 'last view date' property/column)

    ceren



    • Edited by ova c Thursday, May 03, 2012 4:04 PM
    •  
  • Thursday, May 03, 2012 3:42 PM
     
     
    Do you know how this could be accomplished using SharePoint Object Model?  Specifically, looking for the API (object/class that exposes this information).
  • Thursday, May 03, 2012 3:43 PM
     
     

    Hi,

    You only can do this OOTB: http://www.sharemuch.com/2010/12/21/getting-started-with-sharepoint-2010-site-analytics-and-usage-statistics/

    Regards.


    Tomás González. Twitter://@tgmourino

  • Thursday, May 03, 2012 3:46 PM
     
     
    Really cool Idea. It would probably be a custom field control...Im gonna bang one out and put it one codeplex

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

  • Thursday, May 03, 2012 5:38 PM
     
     
    Hi Learn.SharePoint.com - curious how this would be accomplished using a custom field control?  Not sure how soon it will be available on codeplex.  Thanks for any suggestions provided.
  • Thursday, May 03, 2012 10:07 PM
     
     
    So i've been playing with this and there are problems that might make it not a custom field control...but if its not a custom field control i'm wondering what it should be...lemme play for another hour

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com


  • Friday, May 04, 2012 3:30 PM
     
     

    Hey So I thought I could bang this out quickly but my dev env died so I won't be able to get to it until later, but you have two choices, a server-side-rendered choice and a client-side-rendered choice. The server-side-rendered is superior but more difficult. You need to store a value inside your custom field, probably the item ID, and then during the SPField.GetFieldValue  method you'd lookup the audit data and send that out. But getting the item Id into the field means you need to edit every item or add every item as new. This strategy wont work for existing items that you don't want to edit to give the field a value.

    The other way is a javascript way, where while rendering each item you use maybe a custom web service to pass the item ID and get back audit data. This cannot be used for sorting,filtering or custom views though, because its not server side.


    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

  • Monday, May 07, 2012 4:07 AM
     
     Answered

    I have created a custom field type for this.

    see LastViewedFieldType at..

    http://lvft.codeplex.com


    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com

    • Marked As Answer by obautista Tuesday, May 08, 2012 4:14 AM
    •  
  • Monday, May 07, 2012 2:10 PM
     
     

    Hi Learn.SharePoint.com -  this looks very promising.  Can you explain how it works?  I deployed/installed the solution in my dev environment.  I was able to add the custom field type to a doc lib.  Opening/viewing an item does not change the "Last Viewed" column from showing "Never".  Does the solution depend on a timer job running?

    Also, I am not sure what assemblies your solution required, but is it possible to make it a sandboxed solution?  I am looking to use it in a SharePoint Online environment (which I hope is possible).

    Is it possible that the actual source code (Visual Studio solution) be available in CodePlex?

    Thank you so much for this!


    • Edited by obautista Monday, May 07, 2012 2:28 PM added comments
    •  
  • Monday, May 07, 2012 3:25 PM
     
     

    You need to enable auditing (specifically viewing) in your site collection for the field to work, if you've done that then tell me what browser you are using, theres some JS Involved and it might need some improvements to support more browsers.

    Custom Field Types are Farm Solution only, so no you can't use it in Office 365 or the sandbox.

    You'd have to be kind of a JS dev to pull of the solution in office365, and it wont totally work the way I built it, because at times I RunWithElevatedPriviledges.


    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com