Content Type Gallery conflicts

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 have tried the new SharePoint Content Type Gallery you will like it!

Creating Content Types

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 new SharePoint content type gallery is a whole new look to an existing methodology to manage your content types in SharePoint Online.

Content type publishing has changed. Use the new content type panel to view and add recently published content types. To add a content type, go to the library, select Add column, and then select Content type.Learn more about content type publishing.

The warning at the top points towards an article that 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?

Custom Site columns and content type

Imagine that we have created a custom site content type with a custom site column. Now we introduce the same content type in the SharePoint Content Type Gallery. Will this all work?

SharePoint Content Type Gallery

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.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 53

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 SharePoint Content Type Gallery. However we are going to see that warning that I mentioned earlier.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 54

Fixing the content type mess

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.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 55

Then I have some documents in this library and the custom column is visible as well.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 56

When we now try to add the SharePoint Content Type Gallery version of the content type to the site we will get the following error.

Sorry, there was a problem adding this content type. Please try again.

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.

Exporting content types from a site

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>

Updating the SharePoint Content Type Gallery

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.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 59

The tougher road to SharePoint Content Type Galleries

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)

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 60

Then Publish your content type in the SharePoint Content Type Gallery and the Content Type is ready to be added to the library.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 61

Once we have made the content type available on the Library we can update all documents to have a new content type.

SharePoint Content Type Gallery 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.

Using the new SharePoint Content Type Gallery in with existing sites Microsoft SharePoint Online, Microsoft SharePoint image 63

The toughest of roads

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 SharePoint 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.

Other Considerations

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.

Once you have implemented the SharePoint Content Type Gallery, you might want to have a look at the challenges that I found with the Enterprise Content Types created within the SharePoint Content Type Gallery

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

2 thoughts on “Using the new SharePoint Content Type Gallery in with existing sites”
  1. Wow. I knew there were some pitfalls but did not know the extent!

    For Power Platform solutions that use gallery-published Content Types, to help manage the GUID issue we are storing those values inside environment variables as JSON objects. It’s not the perfect answer and certainly doesn’t solve *every* issue, but it helps us a bit with ALM and manual deployments.

    1. For one of my clients recently I was lucky as the columns were properly deployed to many sites. So the GUID and internal name of the columns matched. I just had to update the content types for my content. Painful but doable.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading