sharepoint - Setting author field in SPListItem won't persist -


I am trying to copy a SPILITIT (with file) from one site collection to another. I do this by creating a file like this:

  var archiveFile = newsArchive.Lists [listName] .RootFolder.Files.Add (The original file.name, the original item.file.OpenBarie ( )); Var archiveItem = archiveFile.Item;  

Through a utility method I wrote so I set all the field values ​​of new items to match the original item such as

  utilities .pipul list itemmetadata (. ...)  

The thing is, it remains in the author's area.

I tried to establish the area of ​​the author clearly in every way, for example:

  string user name = original item. Getuusser ("Made by"). LoginName; SPUser user = newsArchive.SiteUsers [userName]; Archive item ["author"] = user.id + "## + user. Login name; ArchiveItem.Update ();  

and do this

  string username = basic item. Getuusser ("Made by"). LoginName; SPUser user = newsArchive.SiteUsers [userName]; Archive item ["author"] = user; ArchiveItem.Update ();  

But as soon as the SPListItem.Update () method is called, the archiveItem ["Author"] field has been returned to the sharepoint \ system. I'm a little bit at a loss here, this should work ..

PS The SPListItem.GetUser method is an extension method

PPS < / Strong> The code is being run from the timer job ...

EDIT: Adding a new field to the content type and then digging something by reflecting that field with the original article's author , But that's not even set up, though, the web.EnsureUser (username) returns the right user, it's weird What!?!

got answer using it

  SPFieldUserValue val = new SPFieldUserValue ( Newschurch, user.id, username); Collection item ["author"] = val; ArchiveItem.SystemUpdate (wrong);  

did the trick!


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -