I am copying over items from one list to another list.

After copying the "Author" field gets populated with "System Account" and so I wish to update some fields in the destination list as follows.

I have a list with a custom Person column named "OriginalAuthor".

I want to replace the value of built-in "Author" with the value of "OriginalAuthor".

I also wish to achieve the same with the modified field (which currently DOES work)

I found a few examples on-line but could not get any to work. So far I have the following:

foreach (SPListItem destItem in destList.Items)
     SPFieldUserValue val = new SPFieldUserValue(web.Site.RootWeb, destItem["OriginalAuthor"].ToString());

     destItem["Author"] = val;
     destItem["Modified"] = destItem["OriginalModified"];

The modified date gets replaced however, the Author field remains the same.

How can I get this to work?

thanks, KS

  • destItem["Author"] = destItem["OriginalAuthor"], this doesn't work? if OriginalAuthor is Person field too, it should! – Arsalan Adam Khatri Oct 24 '12 at 20:23
  • Yes, that's what I thought - but it just doesnt work. – Perplexed Oct 24 '12 at 20:28
  • Perplexed, have a look at this URL, do read at the end of the post - where it says it will not update created by field but posted a workaround by a friend! – Arsalan Adam Khatri Oct 24 '12 at 21:11

Is there a reason you can't grab the Author field from the original item?

My other thought has to do with using SPListItem.SystemUpdate() instead of Update(), but that has more to do with not changing Modified/Modified By than Author.

  • Yes, I tried that, but as suspected it stopped me from updating the modified date and it didnt affect the Author field either. – Perplexed Oct 24 '12 at 20:34

I'm not sure and I cannot test it right now, but i think author field is a person field, so you cannot just put a name there, i think it should be an spuser or maybe some other type which references to user in SP.

Or you can also try this code:

SPList list = web.Lists["myList"];
list.Fields["Author"].ReadOnlyField = false;
SPListItem item = list.Items.Add();
item["Author"] = "value";
list.Fields["Author"].ReadOnlyField = true;

Happy coding


Well after being unable to accomplish this I have decided to use Sharepoint Content Manager to copy the items which preserves the required fields. Thanks to all for your assistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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