I am trying to copy SPListItem (with file) from one site collection to another. I do this by creating a file as follows:
var archiveFile = newsArchive.Lists[listName].RootFolder.Files.Add(originalItem.File.Name, originalItem.File.OpenBinary());
var archiveItem = archiveFile.Item;
using the utility that I wrote, I then set all the field values of the new element to match the original element in this way
Utilities.PopulateListItemMetadata(....)
The fact is that this is not stored in the Author field.
I tried to customize the Author field explicitly for all possible purposes, for example:
string userName = originalItem.GetUser("Created by").LoginName;
SPUser user = newsArchive.SiteUsers[userName];
archiveItem["Author"] = user.ID + ";#" + user.LoginName;
archiveItem.Update();
And so
string userName = originalItem.GetUser("Created by").LoginName;
SPUser user = newsArchive.SiteUsers[userName];
archiveItem["Author"] = user;
archiveItem.Update();
But as soon as the SPListItem.Update () method was called, the archiveItem ["Author"] field returned to sharepoint \ system. I'm a little at a loss, this should work.
PS method SPListItem.GetUser is an extension method
PPS Code starts from timer job ...
: , , , , . , web.EnsureUser( ) . ?!