Wednesday, May 3, 2023

Content Type issue with the PnP Provisioning Engine

 

Often we have a number of Content Types which inherences from each other:











In this case Contoso Document is based on Document, and Contoso is based on the Contoso Document.

The Contoso Project Document is added to the default Document Library on our Contoso Project Template site that serves as the template site for our PnP Provisioning Engine template.







We create the PnP Template and specify the Documents library as it is the only one of interest for us:

Get-PnPSiteTemplate -out C:\temp\basetemplate2.pnp -Force
-ListsToExtract "Documents" -Connection $conn


However, when applying the PnP Template on a new Site Collection we get an error:





OK, so the base type for Contoso Project Type which is the Contoso Document does not exist on this new Site Collection.


This can be resolved in at least two ways:

Either run the PnP PowerShell cmdlet Add-PnPContentTypesFromContentTypeHub and specify that the Contoso Document content type should be added to the target site

or

Add the Contoso Document content type to the document library on our Contoso Project Template Site: 







And once we have applied the PnP Provisioning template to our new site, we can delete both the Document and the Contoso Document content types from the document library, just to ensure that a creative end user doesn't manage to use the wrong content type while working with the document library.