Recently the Content Type Hub in SharePoint Online turned into the Content Type Gallery and this is more that just a rename of a feature.
You might have noticed that when you try to update content types or add new content types that the look and feel of the pages have changed a bit.
The warning at the top ponts towards an article explains some of the changes. All good so far.
If you are tying to enable the Content Type Publishing on existing sites then you might get all sorts of warnings of conflicts.
There is content type name/site column name conflict in My Document Type. To use the content type published from the hub in this site, please take appropriate action.
What is this appropriate action?
Imagine that we have created a custom site content type with a custom site column. Now we introduce the same content type in the Content Type Gallery. Will this all work?
In my Admin center I’m creating the same content type. That is of course as much the same as you can through the user interface. You will notice that the content type GUID is not the same.
Now when I publish this content type from the Admin Center, my content type should appear in my site. Nowadays this even works without the need to subscribe the site to the Content Type Gallery. However we are going to see that warning that I mentioned earlier.
Ok, the straight forward way would be to apply the new content type to all my documents but that may not be that easy. Just imagine having a library with 1000s of documents and you have to update all these documents. What if there was an approval process starting every time we update documents. This could quite quickly become a real mess.
In my test site I have added my content type to my library using the add a content type option.
Then I have some documents in this library and the custom column is visible as well.
When we now try to add the Content Type Gallery version of the content type to the site we will get the following error.
Ok, we are quite stuck now.
The next steps now completely depend on what was done in the past. How were the content types created. If you are lucky you have created site content types and site columns in a scripted way. Site site scripting or PnP Power Shell or any other provisioning method that kept the content type GUIDs the same across all site collections. If you haven’t then there will be a larger job.
I’m going to start with exporting my content type from my example site. Using the following lines of PowerShell I’m collecting the content types and fields.
Connect-PnPOnline https://pieterveenstramvp.sharepoint.com/sites/Site1 -PnPManagementShell
Get-PnPSiteTemplate -Out c:\projects\contentypes.xml -Handlers ContentTypes, Fields
But this gives me all the content types and all the columns. After editing my xml file that is generated I have something like this left:
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
<pnp:Templates ID="CONTAINER-TEMPLATE-4636342D9B124573B394B052C3253FB3">
<pnp:ProvisioningTemplate ID="TEMPLATE-4636342D9B124573B394B052C3253FB3" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
<pnp:SiteFields>
<Field DisplayName="My Custom Site Column" Type="Text" Required="FALSE" ID="{0663842b-e828-4f2c-ae6b-8f616be5e71b}" SourceID="{e47eff89-7549-43e2-b273-33318bb3478d}" StaticName="My_x0020_Custom_x0020_Site_x0020_Column" Name="My_x0020_Custom_x0020_Site_x0020_Column" Group="Custom Columns" CustomFormatter="" EnforceUniqueValues="FALSE" MaxLength="255">
<Default>
</Default>
</Field>
</pnp:SiteFields>
<pnp:ContentTypes>
<pnp:ContentType ID="0x0101002727726D81688A4191DB6D5D33919AFB" Name="My Custom Document Content Type" Description="" Group="Custom Content Types" NewFormUrl="" EditFormUrl="" DisplayFormUrl="" UpdateChildren="false">
<pnp:FieldRefs>
<pnp:FieldRef ID="c042a256-787d-4a6f-8a8a-cf6ab767f12d" Name="ContentType" UpdateChildren="true" />
<pnp:FieldRef ID="5f47e085-2150-41dc-b661-442f3027f552" Name="SelectFilename" UpdateChildren="true" />
<pnp:FieldRef ID="8553196d-ec8d-4564-9861-3dbe931050c8" Name="FileLeafRef" Required="true" UpdateChildren="true" />
<pnp:FieldRef ID="8c06beca-0777-48f7-91c7-6da68bc07b69" Name="Created" Hidden="true" UpdateChildren="true" />
<pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Name="Title" UpdateChildren="true" />
<pnp:FieldRef ID="28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f" Name="Modified" Hidden="true" UpdateChildren="true" />
<pnp:FieldRef ID="822c78e3-1ea9-4943-b449-57863ad33ca9" Name="Modified_x0020_By" UpdateChildren="true" />
<pnp:FieldRef ID="4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb" Name="Created_x0020_By" UpdateChildren="true" />
<pnp:FieldRef ID="0663842b-e828-4f2c-ae6b-8f616be5e71b" Name="My_x0020_Custom_x0020_Site_x0020_Column" UpdateChildren="true" />
</pnp:FieldRefs>
</pnp:ContentType>
</pnp:ContentTypes>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>
Now the next step is to apply this to the Content Type Gallery. We can do this with the below lines of PowerShell:
Connect-PnPOnline https://pieterveenstramvp.sharepoint.com/sites/contenttypehub -PnPManagementShell
Apply-PnPProvisioningTemplate -Path c:\projects\contentypes.xml
Or alternatively I could create my content types and columns using PnP PowerShell by adding the Content type to the Content Type Gallery:
Connect-PnPOnline https://pieterveenstramvp.sharepoint.com/sites/contenttypehub -PnPManagementShell
Add-PnPContentType -Name "My Custom Document Content Type" -Description "My Custom Document Content Type" -ContentTypeId 0x0101002727726D81688A4191DB6D5D33919AFB
Notice that the ContentTypeId has to match all the sites that you want to synchronise. Any custom columns will also have to be replicated. Now as long as your content type IDs in both the Content Type Gallery and the receiving sites are the same, we will be all good.
Also notice that updates may need to be collected for each site. When your content type and columns in the gallery, and the receiving site don’t fully match you might get some warnings asking you to update.
So far I’ve described the almost perfect world. But what if disaster strikes?
You have many sites and your content type and field IDs don’t match?
I’m going to take small steps here.
In my case I’ve got many sites and the content types on these sites were originally provisioning with site scripting. With site scripting a GUID was specified for the fields. This means that the fields on all the sites are identical, however the content types all have a unique ID.
The way froward now can be to create a new content type in the Content Type Gallery as shown below. Make sure that you give the content type a slightly different name than the original. (I named this New Custom… rather than My Custom)
Then Publish your content type in the Content Type Gallery and the Content Type is ready to be added to the library.
Once we have made the content type available on the Library we can update all documents to have a new content type.
Now the above can of course be scripted using Power Shell or Power Automate or any other tool. But for a clarity reasons I’ve used the SharePoint UI here. Because my fields/columns were deployed with a set GUID I’m actually finding that they are remaining available within my list.
So now imagine that we just have sites where content types and columns were created all through the SharePoint UI, either at the site level or even worse at the list level and you want to use the Content Type Gallery. Well now we have a massive job on our hands. This will become a challenging migration project. Each site could be recreated and data migrated from each site to the old site.
Do you have any integrations that are content type aware? Do they expect GUIDs to be in used? You might need to be very careful.
Continue Reading Pieter Veenstra’s Article on their blog
Using the new SharePoint Content Type Gallery in with existing sites
Recently the Content Type Hub in SharePoint Online turned into the SharePoint Content Type Gallery and this is more that just a rename of a feature. Once you
Blog Syndicated with Pieter Veenstra’s Permission