Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The SPListItem.CopyTo() method doesn't seem to work on a custom list or custom properties. When called, CopyTo() returns the error "Source item cannot be found. Verify that the item exists and that you have permission to read it."
Solution: Dorrit Riemenschneider posted this solution in German, Dorrit provides source code you can cut and paste, look for the section in italics near the end of his post: https://www.communardo.de/techblog/2008/01/08/sharepoint-listenelement-splistitem-in-eine-andere-liste-kopieren/
SPListItem offers a CopyTo(destinationUrl) method that doesn't work with a custom list, insteadyou get the exception: "Source item cannot be found. Verify that the item exists and that you have permission to read it."
Dorrit wrote a method that takes the SPListItem and destination list as parameters, and returns a reference to the new list item.
First the method adds an item at the target ___location. Then it steps through and copies each field. Note that we can't copy read-only fields, and attachments require special treatment. Once complete, the target is written with Update() and a reference to the destination element is returned.