Office 365 – SharePoint online: Creating managed metadata column using site script and site design
Recently I came across a requirement to create managed metadata column through site script which should be available after creating the site.
I tried different approaches and tried to find many alternatives but no fruitful information found after tried multiple column schema xml I got it working.
Will start with showing the term store.
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 same as on premise one. There are actually two columns in the list one column is with of type ‘TaxonomyFieldType’ and other column is created with the with 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 actual managed metadata column.
We need multiple GUIDs while creating the metadata column,you need to replace values from your tenant, as follows –
- SspId Taxonomy term store guid
- GroupId Taxonomy term set group guid
- TermSetId Taxonomy term set guid
- TextField Note column guid
Following is the site design JSON file. This include both the columns.( Save content in .json file)
I have created the site design using ‘SharePoint online management shell’
Let’s try now creating new site using the newly created site design.
Looking like we got success with creating new columns.
Let’s add ‘Business Area’ column in document library to test if the column is working or not.
Let’s try uploading new document in library and check if the column is showing the values form term set.
The column provisioned through the site design is working as expected.
Let’s check the TaxonomyHiddenList now.
And if we check by editing item properties you can see same GUIDs we added in JSON file.
Considering 30 verbs limitation (as on date) per site design, this may not be a good solution to spend two verbs for a single managed metadata column.
The purpose of this article is to save some time if anyone have same kind of requirement.
Sharing is caring.