Monday, April 4, 2011

Creating a Taxonomy (Managed Metadata) field (SiteColumn) using definition xml

I was in a situation where I have to create a taxonomy bound site column for our SharePoint 2010 site. First I found it little difficult but SPCAMLEditor gave me a hand in figuring out the Taxonomy field structure in the SharePoint site. One Taxonomy field uses a set of two different fields to store the value.

When I need to create a SiteColumn named "TestColumn", a taxonomy column needs two different fields (TestColumn and TestColumn_0) for the field to work properly

TestColumn is of type "TaxonomyFieldType" and TestColumn_0 is of type "Note". The "TestColumn" references the TestColumn_0 in its field definition as a TextField.

I created the FieldDefinitions by copying the Schema xml to my project as a field definition xml file. When the field definition is deployed to a test server, the field is not saving any of the selected values. It allowed me to select the values but the values are not getting stored. After spending some time, I found that the Schema definition for the "TestColumn" references the ListId and WebId that it was created from in my local machine. Once I removed those references, it started working fine.



















Hope this is helping some one else.

Senthil Subramanian