Managed Metadata Fields in SP2010 Content Type Definitions

30 April 2011

I've been creating some content types in SharePoint 2010 recently, which include a few of the new Managed Metadata Fields, and I came across an issue where items created with the content type wouldn't save, and would leave the following error message:

Failed to get value of the “{0}” column from the “Managed Metadata” field type control. See details in log. Exception message: Invalid field name. {00000000-0000-0000-0000-000000000000}

To the rescue is Ari Bakker, and a fantastic blog post about exactly what you need to do, which you can find in its entirety here - definitely worth a read.

If you just want to skip to the fix, you need to add a Hidden Note field and associate it to your Managed Metadata Column. This is where SharePoint stores the text value of the selected tag, which explains the error message, a little. To do so, just create a hidden field:

<Field Type="Note"
      DisplayName="Type Of Document_0"
      StaticName="TypeOfDocumentTaxHTField0"
      Name="TypeOfDocumentTaxHTField0"
      ID="{C89E9C33-6E67-4604-BFDB-2C5C006CA40E}"
      ShowInViewForms="FALSE"
      Required="FALSE"
      Hidden="TRUE"
      CanToggleHidden="TRUE"
      RowOrdinal="0" />

And add it to your content type using a as per usual. And finally, you'll need to tell the managed metadata field where this Note field lives:

  <Field Type="TaxonomyFieldType" DisplayName="Type Of Document" ID="{79FB1D5E-FACF-4F12-9871-9B68D8623974}" ShowField="Term1033" Group="Custom Columns" StaticName="Type_x0020_Of_x0020_Document" Name="Type_x0020_Of_x0020_Document">
    <Customization>
      <ArrayOfProperty>
        <Property>
          <Name>TextField</Name>
          <Value xmlns:types="http://www.w3.org/2001/XMLSchema"
              instance:type="types:string"
              xmlns:instance="http://www.w3.org/2001/XMLSchema-instance">{C89E9C33-6E67-4604-BFDB-2C5C006CA40E}</Value>
        </Property>
      </ArrayOfProperty>
    </Customization>
  </Field>

There's a few other values for the customization array, which you can find if you grab the sourceXml for a managed metadata site column created on site - I recommend SharePoint Manager 2010 to easily take a look at it.

Tags: content type, managed metadata, SharePoint 2010, SharePoint, site column

Add a Comment

No Comments