Power Community

Power Community

Using the Content Type Gallery in SharePoint Online with existing sites

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.

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.

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 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?

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 Content Type Gallery. Will this all work?

Using the Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online image 52

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

Using the Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online 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 Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online image 55

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

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

When we now try to add the 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:projectscontentypes.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:



  
  
    
      
        
          
          
        
      
      
        
          
            
            
            
            
        
      
    
  

Updating the 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:projectscontentypes.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 Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online image 59

The tougher road to 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 Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online image 60

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

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

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

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 Content Type Gallery in SharePoint Online with existing sites Microsoft SharePoint Online 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 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.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Announcing SharePoint Embedded General Availability

Authored by: Zach Rosenfield Today we’re pleased to announce the general availability of SharePoint Embedded, a new way to build...

More Articles Like This

- Advertisement -spot_img