Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Copy List Item Across Lists

$
0
0

I am copying list items across lists using below code. Works for the most part but the author, created, and modified fields are not getting carried over. How can I preserve them? I tried systemupdate method but that did not help.

//copy sourceItem to destinationList

SPList destinationList = sourceItem.Web.Lists[destinationListName];
SPListItem targetItem = destinationList.Items.Add();

foreach (SPField f in sourceItem.Fields)
 {
     if (!f.ReadOnlyField && f.InternalName != "Attachments")
        {
            targetItem[f.InternalName] = sourceItem[f.InternalName];
        }
  }

Any pointers?

Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>