Phantom Content Types and Site Columns show up in newly created site collections (SharePoint Online)

Mike Sharp 131 Reputation points
2020-12-29T01:04:49.46+00:00

This is a really weird one. I was defining a few site columns and a simple document based content type and ran into problems when they were published to a site collection. I didn't create anything crazy, just an MMS column, a couple text columns, a choice column, a couple date columns and one person/group column. But I couldn't use them on a subscribing site, because something was fundamentally broken with inheritance on them. Eventually I gave up, and started from scratch, and this time everything worked great.

So now I wanted to delete the old site columns and content types (I used different names for the new ones), which I did on the content type hub (e.g. https://MyTenant.sharepoint.com/sites/contentTypeHub). I also deleted the old site columns and content types from the site collection I was working on.

But if I republish any other type of update to a content type, the old content types and columns show up again.

Using PnPPowerShell get-pnpcontenttype, the old content types do not show up in the CTH, nor do the old site columns. They truly don't exist anymore as far as I can tell, yet a newly created site collection will get them when the subscription updates.

If I use that same PnPPowerShell on a site collection, the old content types do show up. I can delete them, and they'll show up again later.

How do I get rid of these things so they don't show up on future sites (or on existing sites)?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,607 questions
0 comments No comments
{count} vote

Accepted answer
  1. ChelseaWu-MSFT 6,316 Reputation points
    2020-12-30T03:11:33.2+00:00

    @Mike Sharp , Thanks for the update.

    Did you delete the content type directly from the Content Type Hub before you unpublish it via Site Content Types > the published Content Type > Manage publishing for this content type > Unpublish?
    If that is the scenario, you need to recreate the old content type in the Content Type Hub with the same name and GUID, so that you can unpublish it and have the system remove it from all sites.
    52070-screenshot-2020-12-30-101743.png

    Here is a sample PowerShell script to recreate the content type in CTH for your reference:

    function New-SPOContentType {  
    	param(  
    		[Parameter(Mandatory=$true,Position=1)]  
    			[string]$Username,  
    			[Parameter(Mandatory=$true,Position=2)]  
    			$AdminPassword,  
    			[Parameter(Mandatory=$true,Position=3)]  
    			[string]$Url,  
    		[Parameter(Mandatory=$true,Position=4)]  
    			[string]$Description,  
    		[Parameter(Mandatory=$true,Position=5)]  
    			[string]$Name,  
    		[Parameter(Mandatory=$true,Position=6)]  
    			[string]$Group,  
    		[Parameter(Mandatory=$true,Position=7)]  
    			[string]$ParentContentTypeID  
    	)  
    	  
    	$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)  
    	$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $(convertto-securestring $AdminPassword -asplaintext -force))  
      
    	$ctx.ExecuteQuery()  
    	    
    	$lci = New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation  
    	$lci.Description = $Description  
    	$lci.Name = $Name  
    	$lci.ID = $ContentTypeID  
    	#paramters.Id and parameters.ParenetContentType cannot be used together.  
    	#$lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID)  
    	$lci.Group = $Group  
    	  
    	$ContentType = $ctx.Web.ContentTypes.Add($lci)  
    	$ctx.Load($contentType)  
    	  
    	try {  
    		$ctx.ExecuteQuery()  
    		Write-Host "Content Type " $Name " has been added to $AdminUrl" -foregroundcolor green  
    	}  
    	catch [Net.WebException]{  
    		Write-Host $_.Exception.ToString()  
    	}  
    }  
       
    # Paths to SDK  
    Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"  
    Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
      
    # Parameters  
    $Username = "<admin@tenant.onmicrosoft.com>"  
    $AdminPassword = "<password>"  
    $AdminUrl = "https://<tenant>.sharepoint.com/sites/contentTypeHub/"  
    $Description = "<Description>"  
    $Name = "<Original Name>"  
    $ParentContentTypeID = "0x0120D520"  
    $ContentTypeID = "0x0120D52000EF84D53385206F439993CB193716595A" #Same in all sites  
    $Group = "Custom Content Types"  
      
    New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID  
    

    References: Contenttype hub publishing old (deleted) content types. / SharePoint Online content types in Powershell: Add.


1 additional answer

Sort by: Most helpful
  1. ChelseaWu-MSFT 6,316 Reputation points
    2020-12-29T04:25:09.087+00:00

    Content type hub syndication is achieved via timer jobs, which are not manageable in SharePoint Online.
    The timer job runs every 4 hours in SharePoint Online, and the more sites or content types you have, the longer it will take for the timer jobs to finish processing changes.

    It seems that you are experiencing delay after you delete the old content types from the Content Type Hub.
    I would suggest you wait for one day and then check the result via a new site again.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    **Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. **