Monday, January 9, 2012

Sharepoint 2010 - Set Editor (Modified By) for Document in Doc Lib

I found many problems to update the field "Modified By" in a document loaded programmatically in a Document Library.

After several attempts I found my solution.

Use the "vti_modifiedby" from ListItem.File.Properties.

Therefore, you must run these lines of code:

spListItem.File.Properties["vti_modifiedby"] = SPContext.CurrentWeb.CurrentUser.LoginName;
//Properties wants string
spListItem.File.Update();

It Works!
It does not works for  Document Set. I have not found the correct procedure.

If anyone knows, write me!