section to the field and hardcode the various Id’s that define a term set (required if you are using a sandboxed solution), or configure these in code.
I’m taking the code approach here as it is the only way to ensure the field will work across multiple environments.
At least in my testing when we create a list definition this isn’t all wired up correctly and the following steps were required.
This and the following step is often missed out in other articles but cause problems if you try to create custom list definitions that include the managed metadata column. The problem stems from the fact that Share Point is looking for an associated note (i.e.
The Taxonomy Field Added feature is not activated on sites created using the blank site template, or sites created using custom site definitions so a good idea is to include a feature activation dependency that ensures this is activated before we attempt to provision our field.
This is easy to do using the Visual Studio 2010 feature editor – just expand the Feature Activation Dependencies section at the bottom and add the following information: Title: Taxonomy Field Added Feature ID: 73ef14b1-13a9-416b-a9b5-ececa2b0604c Description: Register taxonomy site wide field added event receiver Assuming the feature that contains the site columns is site scoped this feature will activate automatically if it isn’t already activated.
The first part of this two part series discussed some of the problems with provisioning Share Point 2010 managed metadata fields.
This post will cover a robust method of deploying Share Point 2010 managed metadata columns in a way that avoids common errors and enables the columns to automatically show up in the search refinement panel.I’ve based the code on Wictor’s excellent example with a couple of minor updates.Instead of hardcoding the name of the term store I’m getting the default keyword store associated with the site (this means we do not have to hardcode the name of the managed metadata service but you should check this works in all your environments).When we add either the site column or content type to a list the managed metadata field works and shows up in the search refinement panel (at least it did in my testing).This is due to the fact that Share Point automatically wires some extra bits (shown below) when the field is added.I’ve also added in some additional error handling so we get informative messages if the metadata service and/or term set does not exist.