DefaultSiteCollectionTermStore == null
Between writing the previous post about provisioning Managed Metadata fields declaratively we decided to remove the hard-coded term store name shown below
var termStore = session.TermStores["Managed Metadata Service"];
and replace it with
TermStore termStore = session.DefaultSiteCollectionTermStore;
We found that while the solution worked locally when we deployed the feature to the SharePoint 2010 UAT server it didn’t work. Turns out that the DefaultSiteCollectionTermStore was null.
After much scratching of heads we narrowed the issue down the way the Managed Metadata Service Proxy had been set up during the installation of the UAT SharePoint server. The IT team responsible for building the UAT servers used PowerShell to automate the building of the server. For the Managed Metadata Service this had a particular impact.
If you highlight the Managed Metadata Service Connection in Central Administration, then click Properties as shown below:
you will see the properties available…
On our development PCs, which had been setup using the Configuration Wizard, all of the available check boxes above were ticked. On the UAT server the opposite was true. Dutifully we ticked all the boxes, hit OK and tried again. Still no joy, so we set up another site collection and activated the feature. This time the feature worked as expected.
Activating the default storage location for keywords and column specific term sets only works for site collections created after the options have been selected (no surprise). At this point we haven’t been able to work out how to associate the default storage with an existing site collection and the easiest option was to delete the site collection, set up a new one and activate the required features.