Back to Postings

Finally after three long weeks of working I got some time to relax and write some personal post. I was feeling that I am paying very little attention to my blog entries and articles. This is because I was working on some SharePoint Migration projects. Don’t think that I was migrating SharePoint 2003 to SharePoint 2007. This migration involves creating a custom solution that can transfer the following items form existing SharePoint sites to new SharePoint Sites.

  1. Lists
  2. Document Libraries
  3. Custom Columns
  5. List Data
  6. Document Libraries Data
  7. Users and Groups
  8. List Permissions
  9. Site Information

In start I thought that would be easy. But it is not. I started working with object model but you would be surprise to note that we can not delete any list fields using some Collection.Delete method inside a loop. Later I got to know that each object get data by query or reference to any change at runtime sent SPException. Later I tried SharePoint Web Services Like, Lists, Views, Permissions, SiteData, but it is a little hard while working with XML and trying to create XML elements programmatically so I decided not to use Web Services much.

I switched to SharePoint Services Object Model and start working with SPList and SPItemCollection Objects. SPFields was my favorite object because I need to transfer a number of custom fields from one WSS Site to another. Another thing to note that to add a Field to List there are two methods ADD, and ADD as XML so this did the trick too. One more note here that Lookup Fields are added to list using ADDLookUp function.

For Document library you will be amazed to know that a document library data structure can never be copied directly from the library to new document library. An example is about a Folder inside a library. If you have multiple folder hierarchy and if you wanted to add some thing to some level of folder in the library what you need to do is Library.Folders[0].SubFolders[0].SubFolers[0].Files.Add(), that was pathetic. Another thing to note that SPFolder object can only have folder upto level like Library\folder1 if you go inside to create another SPFolder it will give the unknown folder exception. So what I did was to get all the library structure and put it in my custom data type. Later I used that data type to create the directory structure in the target site. For file transfer I used fStream objects.

Views transfer was tricky. I have to use Object Model and Web Services Views.asmx at the same time. Why because Microsoft does not provide Microsoft.SharePoint.SPViewCollection.ViewType enumeration directly which should be passed to SPList.Views.Add() function so webService.AddView method get View type as string so I need to use that.

Site permission gets transferred nicely but a thing to note that the target site should have unique permissions J

List permission required Permissions.asmx Web services , SPPermissions and SPMember object so I used all of them in conjunction to to get the result.

Web site information is pretty easy SPWeb Provides all that

List data is also easy if we use SPListItem Class and put the data by matching the fields of the item inside a loop.

So that was all. Last night I tested the solution and send to our client. A 16 hours of QA provide much of the bugs to be removed and application came out to be a good Windows Apps with a nice user friendly interface.

Lastly I will be posting more and more SharePoint 2007 stuff in near future. Specially on the area of Web Content Management, Web Parts, Master Pages etc. Some is referenced and some is my own. So stay tuned.

If some one need that application please do contact me by posting a comment here. Or contact me using This



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s