Problem: 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, which is roughly translated below thanks to Babelfish and a little of my own interpretation. Dorrit provides source code you can cut and paste, look for the section in italics near the end of his post:
Translation: SPListItem offers a CopyTo(destinationUrl) method that doesn't work, at least in my case (a custom list with custom properties and attachments, maybe I expect too much of SharePoint). Instead I receive the exception: "Source item cannot be found. Verify that the item exists and that you have permission to read it." A quick Google search revealed that other people had the same problem but no solution. And so I bring you a method that works.
The method 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.
The first meeting of TSPUG in 2008 will feature the return of Reza. Lately he's been working on custom authentication providers for SharePoint, and next Wednesday you'll learn just how easy these are to build and deploy (when you know the tricks; there are always tricks). See you there!
When: Wednesday, January 16, 6:00pm to 8:30
Where: 2 Bloor West (NW corner of Yonge and Bloor), 8th Floor
Topic: Custom authentication
providers in SharePoint 2007
Abstract: In ASP.NET 2.0 , there is an important
concept called the authentication provider model which is used for many new
features such as Membership and Role Management, Profiles, etc. Moss 2007 is built
on the top WSS 3.0 which is in turn built on the top of ASP.NET 2.0. This means
that both MOSS and WSS can utilize everything that ASP.NET 2.0 offers. In this
session learn how to create a custom authentication provider, how to set up forms
based authentication, get yourself familiar with issues/workarounds, manage
your custom profiles and finally how to leverage this solution to expose your
SharePoint sites to the external users. This session is targeted at both IT
pros and developers.
About the speaker: Reza (MOSS MVP,MCTS)is
currently working for Protech as
principal architect where he is in charge of architecting and implementing
various technologies to support the organization. Since 2001, his focus has been Collaboration platforms, Knowledge Management, and Business Process Management. Reza
frequently speaks on a variety of SharePoint related topics at user group
meetings and industry events. For his community involvement and contributions,
he was awarded the Microsoft MVP award for SQL Server Reporting Services (2004-2005)
and Microsoft Office SharePoint Server (2007-).
RSVP Here! (Link opens new e-mail)
The long arm of MSDN Canada reached out to me to do a Q&A on their Developer blog:
MVP Insider - Q & A with Eli Robillard
Biggest surprises? I can eat 102 popcorn shrimp in a single sitting, and refuse to shave until Pope Benedict canonizes James Brown as a saint.