Office 365: Taxonomy fields on newly created site

Site creation

Office 365 provides great and really fast way to create a new modern site collection (do you remember how long it took to provision a classic site?). It helps a lot to boost users experience as they can see almost immediate results.

However, in most organizations there is a requirement to execute provisioning of additional assets based on ‘site designes’ or ‘pnp templates’. Recently, I have faced a situation when wanted to apply PnP provisioning template to a newly created site that contained content types with taxonomy fields.

SP Taxonomy fields

Just as a quick reminder, to use taxonomy fields it is required to add 2 special fields to a list/content type. These are:

  • TaxCatchAll
  • TaxCatchAllLabel

Which are lookup fields and point to the TaxonomyHiddenList. You can find deep explanation of those roles in a fantastic article of Andrew Connel Managed Metadata: In Depth Look into the Taxonomy Parts.

In fact, these fields are not created immediately after the sites creation, but are added later. Most probably by a timer job, as they are available on the site more or less after 5-6 minutes after site creation. But why do we have to wait that time to get what we really need?

Taxonomy hidden fields provisioning

After trying few other times to force O365 to provision those fields for me, I have decided – OK, they are not there, so let’s create them. However, to execute provisioning of those fields – we need one prerequisite. As we have already said, these are lookup columns and point to taxonomy hidden list, so we have to be sure that it exists before the provisioning.

We can easily ensure it by activating the taxonomy site scope feature:

After that, we need to get it’s Id and pass it as a parameter to our provisioning template as a parameter. After we can execute the provisioning of required fields:

Here is the content of the provisioning template:

Thanks to this approach, you won’t need to wait till O365 will provision required fields to deploy your stuff. Enjoy!

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s