Creating Managed Metadata Column Using Site Script And Site Design

Recently I came across a requirement to create managed metadata columns through site script which should be available after creating the site.
 
I tried different approaches and tried to find many alternatives but I found no fruitful information. After I tried multiple column schema xml I got it working.
 
I will start by  showing you the term store.

Creating Managed Metadata Column Using Site Script And Site Design

I have created a sample group ‘Test Group’ and underneath it a term set named as ‘Business Area’ with some sample terms.
 
Managed metadata column in SharePoint online works the same as the on premise one. There are actually two columns in the list -- one column is of type ‘TaxonomyFieldType’ and the  column is created with the format fieldnameTaxHTField0 of type Note. 
 
The Taxonomy column holds Term name and a lookup with the TaxonomyHiddenList. TaxonomyHiddenList can be found at /Lists/TaxonomyHiddenList/AllItems.aspx. This list will hold the details of the terms that are used in any managed metadata column.
 
Hence for creating managed metadata column through site design we need to create two columns, one of type Note which we need to use while creating the actual managed metadata column.
 
We need multiple GUIDs while creating the metadata column, as follows,
  1. SspId Taxonomy term store guid
  2. GroupId Taxonomy term set group guid
  3. TermSetId Taxonomy term set guid
  4. TextField Note column guid
Following is the site design json file. This includes both the columns.
  1. {  
  2.     "$schema""schema.json",  
  3.     "actions": [  
  4.         {  
  5.             "verb""createSiteColumnXml",  
  6.             "schemaXml""<Field ID=\"{6B9ACD15-717D-4A39-B375-7613949F14D5}\" Type=\"Note\" Name=\"BusinessAreaTaxHTField\" StaticName=\"BusinessAreaTaxHTField\" DisplayName=\"BusinessAreaTaxHTField\" Group=\"Test group\" ShowInViewForms=\"FALSE\" Required=\"FALSE\" Hidden=\"TRUE\" CanToggleHidden=\"TRUE\" />"  
  7.         },  
  8.         {  
  9.             "verb""createSiteColumnXml",  
  10.             "schemaXml""<Field Type=\"TaxonomyFieldType\" Name=\"BusinessArea\" StaticName=\"BusinessArea\" DisplayName=\"Business Area\" Group=\"Test group\" ShowField=\"Term1033\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Mult=\"FALSE\"> <Default></Default> <Customization> <ArrayOfProperty> <Property> <Name>SspId</Name> <Value xmlns:q1=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q1:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">{d0e6060b-5eea-4d8e-92f5-85289a07c81c}</Value> </Property> <Property> <Name>GroupId</Name> <Value xmlns:q2=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q2:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">343a6ffa-cce2-44b2-9249-3e56db95264e</Value> </Property> <Property> <Name>TermSetId</Name> <Value xmlns:q2=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q2:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">746a0c2e-422c-416e-ad28-da9409be8fef</Value> </Property> <Property> <Name>TextField</Name> <Value xmlns:q6=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q6:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">{6B9ACD15-717D-4A39-B375-7613949F14D5}</Value> </Property> <Property> <Name>AnchorId</Name> <Value xmlns:q3=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q3:string\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">00000000-0000-0000-0000-000000000000</Value> </Property> <Property> <Name>IsPathRendered</Name> <Value xmlns:q7=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q7:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value> </Property> <Property> <Name>IsKeyword</Name> <Value xmlns:q8=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q8:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value> </Property> <Property> <Name>Open</Name> <Value xmlns:q5=\"http://www.w3.org/2001/XMLSchema\" p4:type=\"q5:boolean\" xmlns:p4=\"http://www.w3.org/2001/XMLSchema-instance\">false</Value> </Property> </ArrayOfProperty> </Customization> </Field>"  
  11.         }  
  12.     ],  
  13.     "version": 1  
  14. }  
I have created the site design using ‘SharePoint online management shell’

Creating Managed Metadata Column Using Site Script And Site Design
 
Let’s try now creating new site using the newly created site design.

Creating Managed Metadata Column Using Site Script And Site Design
 
Looks like we got success with creating new columns.

Creating Managed Metadata Column Using Site Script And Site Design
 
Let’s add ‘Business Area’ column in document library to test if the column is working or not.
 
Creating Managed Metadata Column Using Site Script And Site Design 
 
Let’s try uploading a new document in the library and check if the column is showing the values from term set.
 
Creating Managed Metadata Column Using Site Script And Site Design 
 
The column provisioned through the site design is working as expected.
 
Let’s check the TaxonomyHiddenList now.
 
Creating Managed Metadata Column Using Site Script And Site Design 
 
And if we check by editing item properties,
 
Creating Managed Metadata Column Using Site Script And Site Design 
 
Considering the 30 verb limitation (as on date) this may not be a good solution to use two verbs for a single managed metadata column.
 
The purpose of this article is to save some time if anyone has the same kind of requirement.
 
Sharing is caring.