Microsoft Office Sharepoint

All my posts are provided "AS IS" with no warranties, and confer no rights.

Modified By Column does not get updated

Modified By Column does not get updated

  • Comments 1
  • Likes

Have you ever seen the following behavior ?

You create a new document library and start uploading content.Then the users start modifying the documents, however, the Modified by  field does not update to reflect the Name of the user that modified the document. Instead, the Name of the user that created ( or otherwise the first user that modified the document ) is displayed.

Why ?

The Explanation resides in the Modified by Field Definition as it is defined at the list Level.

An out of the box Editor field has the following SchemaXML (as , for example in http://msdn.microsoft.com/en-us/library/dd931513(v=office.12).aspx ):

 <Field ID="{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}" ColName="tp_Editor" RowOrdinal="0" ReadOnly="TRUE" Type="User" List="UserInfo" Name="Editor" DisplayName="Modified By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Editor" FromBaseType="TRUE"/>

 if you retrieve the SchemaXML of your field through Powershell, you may notice the following differences:

  • you have Version="1" in the Definition
  • FromBaseType="TRUE" is missing

ex:

 <Field ID="{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}" ColName="tp_Editor" RowOrdinal="0" ReadOnly="TRUE" Type="User" List="UserInfo" Name="Editor" DisplayName="Modified By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Editor" Version="1"/>

 This means:

  • the field is customized and it's definition was modified from OOB

If you do not have this differences STOP here and look for other potential reasons. If you do, read further.

 

You may ask : "yes, but I created a brand NEW document library and I have not customized anything, how come it is customized?"

The answer is simple: the field is customized at the web level (or even higher, if you use content type hub and modified this at the hub level), which means, each document library will be created with the "modified" field.

How to solve this (do not ask how repair the actual value of the field so that it reflects the last modified user, that would be a scripting exercise to retrieve the Name of the user from the actual document properties, then set the value of the Editor Field at the SPListItemLevel to that value)

To revert the functionality and make the field "behave" :) you need to :

  • repair the field's SchemaXml at the Web level (so that the future document libraries do not get created with the wrong field)
  • repair the field's SchemaXml at the Doclib level

now on to scripting ( if you use a Content Type hub, you need to go at the hub level and fix the definition at the source, then propagate the field downwards):

At the web level

 

$s = get-spsite http://tcos
$w = $s.OpenWeb("/weburl/")
$f = $w.Fields.GetFieldByInternalName("Editor")


if ($f.SchemaXML -match 'FromBaseType="TRUE"')
{
write-host "field at "  $w.Url " is ok " $f.schemaxml
}
else
{
#add at the end of the schema the needed string


$f.SchemaXML = $f.SchemaXML -replace '/>','FromBaseType="TRUE" />'
$f.Update()

}

At the List level :

$s = get-spsite http://tcos
$w = $s.OpenWeb("/weburl/")
$l = $w.Lists["myBrokenList"]
$f = $l.Fields.GetFieldByInternalName("Editor")
if ($f.SchemaXML -match 'FromBaseType="TRUE"')
{
write-host "field at " $w.Url  " List "  $l.Title  "  is ok " $f.schemaxml
}
else
{

#add at the end of the schema the needed string and update the field and list

$f.SchemaXML = $f.SchemaXML -replace '/>','FromBaseType="TRUE" />'
$f.Update()
$l.Update()


}

 

The Field Version will increase but this should not bring any problems. If you want to script this over all the lists, encompas the code above in a foreach block.

And, of course , although the operation is pretty trivial, straightforward and reversible through the same procedure, safety first, ALWAYS make sure you have working backups :)

 

Cheers.

Comments
  • Many thanks for the post, massively appreciated, sorted my issue.

    Small issue, if there is no space between the last attribute and cliosing tag, en exception is thrown.

    Changing the replace line to (added space before From...):

    f.SchemaXML = $f.SchemaXML -replace '/>',' FromBaseType="TRUE" />'

    Solves this.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment