4

We changed domains and I need to updated the User fields in all lists and libraries to reflect the new domain accounts. (I know that stsadm.exe -o migrateuser will mostly handle this but since it disables any existing new accounts it does not handle the list items and documents that are already pointing to the new domain account.)

Anyways, my problem is updating the "Editor" or "Modified By" field. If I use the UpdateOverwriteVersion() method the field is properly updated but with the side effect of the "modified timestamp" being changed. If I use the SystemUpdate(False) method, the updated field is ignored and does not reflect the new account.

What can I do to get the field to update without changing the associated timestamp?

1 Answer 1

4

After some further research (no help) and experimenting (helpful) I figured out what needs to be done. It seems that two things need to be done in order to update the "Modified By" field while leaving the "Modified" (timestamp) field alone.

Set the "Modified" field value to itself

Use the UpdateOverwriteVersion() method

Dim items As SPListItemCollection
items = some_list.Items

For Each i As SPListItem in items
   Dim activeUser As SPFieldUserValue = New SPFieldUserValue(i.Web, 27)    ' some user

   item.Item("Editor") = activeUser                       ' set to new user
   item.Item("Modified") = item.Item("Modified")          ' set to same value

   item.UpdateOverwriteVersion()
Next

Obviously, internally, setting the value of the Modified field to itself is marking the field as "dirty" and to indicating that it should be used instead of the current date/time.

1
  • Didn't know that UpdateOverwriteVerion existed, works the same in c#. Jun 2, 2014 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.