Scenario:

You have some kind of SharePoint List that is populated with data from some source. You require that some of the fields are read-only in SharePoint so that users cannot change them. You also have versioning turned on to track any updates to the list items whether it comes from the importing process or user changes.

Issue:

If the fields are marked as read-only, SharePoint will not display information about these fields on the version history page (versions.aspx) even if the values had changed. There is no option to change this in the web UI.

versionhistory1

This list item has 50+ fields but is not showing fields that are read-only.

Solution:

In order to display the versioned values of fields that are read only, you have to change the SPField.ShowInVersionHistory property to True.

Now the item's version history will show the changed values for all fields even if they are read-only.

Now the item's version history will show the changed values for all fields even if they are read-only.

Powershell Script

Here’s a Powershell script snippet that can change this property in a jiffy assuming you have all the fields in a column group.

[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$site = new-object Microsoft.SharePoint.SPSite("http://sharepointsite")
$web = $site.rootweb
$list = $web.Lists["Your List"]
$fields = $list.Fields
$count = 0
for($x = 0; $x -le ($fields.Count-1); $x++)
{
    $field = $fields[$x]

    if($field.Group -eq "Custom List Columns" )
    {
        Write-Host $field.Title
        $field.ShowInVersionHistory = 1
        $field.Update()
        $count++
    }
}
$web.Dispose()
$site.Dispose()
Write-Host "Updated $count fields"