Thursday, April 2, 2015

Migrating Lists - Using list templates SharePoint 2013

Recently I came across a strange & unusual behaviour in SharePoint 2013. I was moving stuff from the dev environment to production. One of the most basic task is to move lists. So the usual process of taking a list template from dev to production and creating a list out of the list template.

But, Microsoft decided that we will not allow this from SharePoint 2013. Let developers learn some (unnecessary) new stuff. So, the above mentioned basic concept of moving a list will not work in SP 2013. I have absolutely no clue as to why.

So the new approach is to use powershell script to create list from the templates. Its a HACK I know, but MS still allows us to do it.

First you have to save the list as template and then upload that to production list template gallery.
Then change some values below and run it in PowerShell. Thats it, you list will be created.

# Get the SiteURL
$site = get-spsite("http://YourSite/")
# Get the Articles web
$web = Get-SPWeb -Identity "http://YourSite/SubSite/"

# Get the custom list templates
$CustomlistTemplates = $site.GetCustomListTemplates($web)
#Create the custom list using template
$web.Lists.Add("YourList", "YourList", $CustomlistTemplates["Your_List_Template"])
Write-Host "Based on the template YourList Created"


Thanks to Santosh Babu for the detailed writeup.

Happy Learning