This project is read-only.
SharePoint Archived Record Latest Version Flag and Version Append Event Receiver
Sandboxed Solution

Sets the "Latest" Yes/No column for prior records in a Record Library whenever a new version is added to the library based on a filename version suffix for files with the same File Name (prior to the last underscore). Ex: "DocumentName_1.0.docx" and DocumentName_1.2.docx" will be considered the same File Name and will set only the latter to Latest based on the dot delimited version number after the underscore. Works with up to 12 digit major and minor version numbers.

SPLatestVersion release 1.1 and later will also rename the file automatically using a single line of text column named "CurrentVersion" in the Record Library if the version number was not manually populated. Ex: FileName.docx will be renamed FileName_001.001.docx if the CurrentVersion column is 1.1

Purpose: Apply when a document's version history metadata needs to be reported on via a view, SSRS, Excel, or other reporting tool and the latest versions need to be identified or filtered on. This should be used in conjunction with a workflow or event handler that copies these file versions from another document library to the record library whenever Checked-In or Published. This process could utilize a custom "CurrentVersion" column entered by the document owner. Alternatively, the documents can be manually named and uploaded. The "Latest" field should also be hidden from edit forms since the user need not edit it and doing so would be futile.

Note: I chose not to rely on the version column in the record library, because the column would not sort correctly as an integer or text and as such is fairly useless. The files had to be uniquely named to fit in the same record library, so the filename version suffix was the best solution. Using a minor and major version column could have worked, but would have been ugly from an end user perspective. You can implement major and minor version calculated columns based off the title for view sorting if desired.
Ex: (1.1, ..., 1.8, 1.9, 1.10) should order as displayed here

The code can be easily modified to work against a standard document library, with different delimiters, or with a differently named column. Ex: "Current, Active, Recent, Published, Live, etc." (Change ListTemplateId and/or strLatest in code) But as compiled it will only work with a Record Library

One additional suggestion is adding a manually entered "Retired" field and a calculated "Active" Field which is only true if "Retired" = false and "Latest" = true.

See for instructions

Last edited Jun 21, 2013 at 7:03 PM by RobertRFreeman, version 25