Answered How to display side-by-side versions

  • Wednesday, July 27, 2011 1:29 PM
     
     

    Need to display the last approved Document /w properites (this is what Readers see) to an Administrator (or Approver) with the pending unapproved Document & Properites side-by-side on a single web page.

    The problem is Administrators only have access to the pending work, and will never see what a Reader sees OOTB.

    Possible workaround to access this last approved document; nothing in the API seems to allows this?  (Assume Versioning is off in the document library; so not an option to look at past versions).

    Thanks in advance

Answers

All Replies

  • Friday, July 29, 2011 6:09 AM
    Moderator
     
     

    You can make use of the SPListVersion( http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemversion.aspx ) in SharePoint object model. I have tried the following PowerShell:

     

    $web=get-spweb http://yoursharepointsiteurl/

    $dl=$web.lists[“Your document library name”]

    $item=$dl.items| where {$_["Your document filter column name"] –eq “your document filter column value”}

    $currentPublished=$item.versions |where {$_.isCurrentVersion –and $_.Level –eq “Published”}

    $currentDraft=$item.versions | where {$_.isCurrentVersion –and $_.Level –ne “Published”}

     

    You can then display the value of the document item property with $currentPublished[“thePropertyName”] and $currentDraft[“thePropertyName”]



  • Friday, July 29, 2011 1:44 PM
     
     

    This will only work with Versioning turned on and then you need too dicker with versions.

    When versioning is off; two versions still exists, but the API does not allow access to it without changing the context of the user which is accessing ListItem.

    I guess this is a design change to give administrators access the to current published content.  This would be easier then the above querying of versions; which may not be enabled.

    With Versioning off, what does $item.versions object contain? Published, Pending, & Draft.

  • Monday, August 01, 2011 2:06 AM
    Moderator
     
     Answered

    My test result is that when versioning is turn off, I can still get the old versions created when versioning was on;

     

    And if content approval is on, two versions still exists: draft version and published version;

     

    If you cannot get all these version with API, you may try runwithelevatedprivilage: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx