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 am trying to use sharepoint foundation 2010 as file store for a website. Every document update must go thru an approval cycle and finally gets to a approved status to show up on the website for end users. When a document is updated in sharepoint the status is reset to "Draft" even if the previous version was approved. This is the intended behavior.

File.Versions gives me the list of versions.

How to get the version that was last "Approved"?

share|improve this question
1  
By Client OM do you mean C# OM or rahter Javascript OM? The JS OM does not allow to my knowledge Versions access, rather through the use of SOAP Web Services –  C. Marius - MVP Jan 12 at 14:15
add comment

2 Answers 2

If you loop through the File.Versions you can find the one with the IsCurrentVersion property set to true. That should be the most recently approved version.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.fileversion_members(v=office.14).aspx

share|improve this answer
add comment

Please use below code and this will give latest approved version.

SPList oList = new SPSite("http://developerBOX1").AllWebs["Web1"].GetList(
                    "http://developerBOX1/Web1/DocLIB");
SPListItemCollection collListItems = oList.Items;
SPListItem itemFound;
if (oList.EnableVersioning){
    foreach (SPListItem oListItem in collListItems)
{
SPListItemVersionCollection allVersions = oListItem.Versions;          
// Iterate through all versions         
foreach (SPListItemVersion version in allVersions){
    if (version.Level == SPFileLevel.Published){
        itemFound = version.ListItem;
        return;
    }
 } 
share|improve this answer
    
Thanks.. trying to find SPListItem in CLOM. is this from Webservices by any chance?? –  Bhuvan Apr 3 '12 at 22:08
    
hi bhuvan the CLOM encapsulates sharepoint webservices and gives you a ease of use API –  Sebastien Stettler Apr 4 '12 at 7:42
    
You can write this code in a web service and use this services in your website. I hope this will help you –  Yogi Apr 4 '12 at 12:22
    
Hi Bhuvan, Will this solution help you in your requirment, Please let me know? –  Yogi Apr 4 '12 at 14:05
1  
The confusion is that the question specified the use of the Client Object Model (CSOM) and the answer given shows code from the Server Object Model. –  Rob Windsor Aug 24 '13 at 2:49
show 2 more comments

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.