Wednesday, May 30, 2012

SharePoint versioning fails

I recently came across a document library at a customer with major versioning only. When checking for a particular version of a file using SPFile.Versions object we came across a strange error.

Despite the fact that version 1.1 exists as illustrated by the picture below

when checking the SharePoint API for the Versions collection there's only one version of the file, namely version 1.0, internally numbered 512.

As we use SharePoint for document management we sometimes need to retrieve a particular version of the file, in this case version 1.0. But checking SharePoint's versioning system we're told that the latest version is 1.0 - not 1.1. This might be due to the fact that minor versioning has been turned on at one point in the document library - but we don't know.

As SharePoint says the latest version is 1.0 we'll get the wrong file version when trying to retrieve version 1.0. As SharePoint says 1.0 is the latest version we'll retrieve this version of the file despite the fact that version 1.1 is the latest version.

Checking out and checking in the file changes the latest version to 2.0.

I find it quite surprising that SharePoint still 10+ years after the first release have these basic errors. It makes it very hard to provide a robust document management system on top of SharePoint as we have to solve all these errors in our document management level of code on top of SharePoint.

No comments: