Changing SharePoint Metadata on Records Managed by Collabware
Metadata on our SharePoint documents can and often are part of the record itself. The modified by, modified date, created by and created date are of course important but are not modifiable by end users outside of simply using SharePoint unless you can write code and have access to the sever.
Solution specific metadata like Vendor, Approved By or email metadata like To, From and Subject though may be a critically important aspect of the record and aid in discovery. Therefore, when Collabware declares an item as a record in SharePoint and marks the content immutable, the metadata along with that document will necessarily also be protected.
However, we don’t live in a perfect world and sometimes you may have a valid reason for changing the metadata on a document after it has become a record. For example, if you want to set the project end date on a series of documents to drive retention or change the name of a department on documents after a company reorganization to ensure findability or properly assign the individuals for content review during disposition.
Collabware does offer the ability to undeclare records, but doing so will leave our content susceptible to deletion, pollute out audit trail unnecessarily and add effort to the ongoing maintenance of the solution.
One of the key and correct decisions that Collabware made was to leverage the record locking functionality offered by SharePoint instead of creating their own locking mechanism. So it’s possible for us to leverage SharePoint’s Record Management API for certain tasks when dealing with records.
Here’s an example PowerShell script that leverages SharePoint's Records Management API to modify a Comments field by passing a delegate to the byPassLocks method (note this will need to be run under an all-powerfull Farm Administrator account:
[void] System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.RecordsManagement.RecordsRepository.Records")
if(-not(Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})) { Add-PSSnapin Microsoft.SharePoint.PowerShell;}
$recordsmanagement=[Microsoft.Office.RecordsManagement.RecordsRepository.Records]
#Delegate method to change the metadata on a document$ChangeRecord = { param( [Microsoft.SharePoint.SPListItem] $item ) $item["Comments"] = "Comments changed on record by ByPassLocks Delegate" $item.Update() }
#get the web$web = Get-SPWeb “http://portal.collabware.com/sites/Demo”
#get the library$list = $web.lists["Commented Documents"]
foreach($item in $list.Items) { #pass the delegate to the By Pass locks API $recordsmanagement::bypasslocks($item, $ChangeRecord)}