Karine Bosch’s Blog

On SharePoint

Declaring a taxonomy field that allows multiple values


There are two different types of taxonomy fields:

  • TaxonomyFieldType: This defines a taxonomy field to store a term to tag the list item.
  • TaxonomyFieldTypeMulti: This defines a taxonomy field that allows users to tag the list item with more than one term from the same term set.

When using CAML, you can declare taxonomy fields as follows:

  <Field  ID="{CB736B25-C980-4688-B076-1C5315B20092}" 
          Name="ProductCategory" DisplayName="Product Category" 
          Type="TaxonomyFieldType"
          ShowField="Term1033" 
          EnforceUniqueValues="FALSE" 
          Group="XYZ Site Columns" 
          SourceID="http://www.xyz.be/v1" />

  <Field  ID="{6E8C115D-43DE-4AD9-9DE4-27F5D4C008F4}" 
          Name="ProductCategories" DisplayName="Product Categories" 
          Type="TaxonomyFieldTypeMulti"
          ShowField="Term1033" 
          EnforceUniqueValues="FALSE" 
          Group="XYZ Site Columns" 
          SourceID="http://www.xyz.be/v1" />

This will create your field of the correct type but it will not be mapped to a term set yet. This cannot be done through CAML, but only through code, ideally in the feature receiver:

   field.SspId = termStore.Id;
   field.TermSetId = termSet.Id;
   field.AnchorId = Guid.Empty;

These properties mean:

  • TermSetId: This is the Guid of the term set to which the field is mapped. Users will only be able to tag the item with term(s) from this term set.
  • AnchorId: If the entry point for tagging is a term within the term set, the anchor id needs to be set to the guid of this term. If the entry point for tagging is any term within the term set, this property does not need to be set.
  • SspId: This is the Guid of the term store to which the term set belongs.

You would think that, when you create a field of type TaxonomyFieldTypeMulti, you would be able to store more than one term, but unfortunately that’s not the case.

When you inspect the field in the user interface, you see that the check box Allow multiple values is not checked.

It’s only after having checked this property that you are able to store more than one term using the TaxonomyFieldValueCollection. Unfortunately there is no attribute in CAML to set this checkbox, so you will have to solve this in your feature receiver by setting the AllowMultipleValues property:

if (field.TypeAsString == "TaxonomyFieldTypeMulti")

      field.AllowMultipleValues = true;

As of then you will be able to store multiple terms in the taxonomy field.

December 20, 2013 - Posted by | SharePoint 2010, SharePoint 2013

9 Comments »

  1. Wouldn’t that be the Mult=”TRUE” attribute on the Field? That’s what it took in 2010.

    Comment by Erich Stehr | December 22, 2013 | Reply

    • Didn’t know that. Thanks for the tip! I’ll try it out and if so, I’ll modify my post.

      Comment by Karine Bosch | December 23, 2013 | Reply

    • Yes, with Mult=”True” works

      Comment by Alan | August 18, 2016 | Reply

  2. what should be there in the field ?

    Comment by siddhardh | May 15, 2015 | Reply

    • Can you elaborate a bit more on your question? I’m not sure I understand.
      Kind regards,
      Karine Bosch

      Comment by Karine Bosch | May 15, 2015 | Reply

  3. While there is no attribute, Feature Receiver is NOT the only solution. in CAML, you can use type=TaxonomyFieldTypeMulti instead of TaxonomyFieldType

    Comment by Ashish Patel | May 29, 2015 | Reply

    • Hi Ashish,
      Thanks for your reply. If I remember well, at the time I tested it out, TaxonomyFieldTypeMulti didn’t set the multi value checkbox, but it’s possible that this was on SP2010. I’ll test it out on both environments this weekend, and I’ll adapt my blog post if needed.
      Kind regards,
      Karine Bosch

      Comment by Karine Bosch | May 30, 2015 | Reply

  4. is there any option to select the default value of taxonomy field

    Comment by Rahul Barua | May 4, 2016 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: