3 April 2012

Managed Metadata - moving from test to production

Suppose you have a development machine which contains the model you want to deploy into production.  Suppose that Microsoft have provided a way to import Terms into the Term Store but no export mechanism.  You have two, well, three choices:
  1. Write a console app that writes out CSV files in the format MS have defined, use the import mechanism to move it across.
  2. The same but with Powershell.  This is slightly easier and there are a lot of examples.
  3. Use the method below I'm about to tell you about, still with PowerShell, to move the whole term store.
It's important to realise that while choice 1 and 2 will work, they will leave you with different GUIDs on the terms which means that you will have to relink them.  This could be a real pain if you are moving across document libraries and other content which already links to the terms.  Ideally we want to dump the whole term store from dev and bring it back on the production farm.  Fortunately, we can do that using a few lines of PowerShell through the SharePoint 2010 Management Shell:

On your development box, start the Management Shell and paste in the following (adjust this if you renamed your Managed Metadata service):

$mmsApplication = Get-SPServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
$mmsProxy = Get-SPServiceApplicationProxy | ? {$_.TypeName -eq "Managed Metadata Service Connection"}
Export-SPMetadataWebServicePartitionData $mmsApplication.Id -ServiceProxy $mmsProxy -Path "\\server1\share\mmsdata.cab"


On your production farm, start the Management shell and paste in the following (again, adjust to taste):

$mmsApplication = Get–SPServiceApplication | ? {$_.TypeName –eq "Managed Metadata Service"}
$mmsProxy = Get–SPServiceApplicationProxy | ? {$_.TypeName –eq "Managed Metadata Service Connection"}
Import–SPMetadataWebServicePartitionData $mmsApplication.Id –ServiceProxy $mmsProxy –Path "\\server1\share\mmsdata.cab" –OverwriteExisting

You should now have moved your term store from your dev farm to your production farm.  Note that the -OverwriteExisting argument does just that so take care!

2 April 2012

List Definitions the Easy Way

I discovered today that you can create a list definiton by saving your list as a template.  Although it still has a .stp extension (as it did in SP2007) instead of saving a file full of binary it creates a zipped archive which can be opened.  The file contains the xml required to paste into a blank list definition.  Much easier than cooking up your own from scratch!

Read this for more info:-
http://onlinecoder.blogspot.co.uk/2011/03/simple-way-of-creating-sharepoint-2010.html