I was working on a project today and one of the requirements was, using a Timer Job, run an Export of an existing site collection and then Import it as a new site collection. The code to do this was relatively straight forward. But then when testing I found that the site collection being copied was (intentionally) still in SharePoint 2010 mode (experience).

The change was simple. There is an override when creating a new SPSite that lets you pass in the CompatibilityLevel. The value for the CompatibilityLevel parameter can be either 14 (for SharePoint 2010) or 15 (for SharePoint 2013). You must also pass in the WebTemplate, which for a Team Site, is STS#0.

Here is an example of what the code could look like:

using (SPSite osite = contentDB.Sites.Add({SiteURL}, {SiteName}, String.Empty, 1033, 14, "STS#0", {OwnerLogin}, {OwnerName}, {OwnerEmail}, {SecondaryContactLogin{, {SecondaryContactName}, {SecondaryContactEmail}))

	// Execute your code

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.