Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierFlux principal

Cleaning Up Content Types Orphaned from the Content Type Hub

One of my clients who doesn’t have a blog came up with a good fix the other day. Since he didn’t have a place to put it, he offered it to me to post.

Have you ever deleted a Content Type from the Content Type Hub which you had previously published – without unpublishing it first? If so, you probably have that Content Type sitting in all your Site Collections (now modern sites) and you can’t delete it because it came from the Content Type Hub.

Well, there’s a fix for that. The article I list in the Resources section below gets you there for on premises versions of SharePoint, but it says for SPO you should open a ticket with Microsoft support. (Comments about Microsoft support withheld.) No support ticket required.

If it’s a wholesale problem (lots of orphaned Content Types), then the script in the article will be helpful. After all, you need to figure out which Content Types are actually orphaned first. But if you know a specific single Content Type is an issue, you can simply recreate it using the original Name and Id.

Here’s an example, using PnP.PowerShell, of course! The important bit is line 5, where you recreate the Content Type which is orphaned. Obviously, you would use your own:

  • Tenant Name
  • Name
  • Id
  • Group
$cth = "https://sympmarc.sharepoint.com/sites/contentTypeHub"

Connect-PnPOnline -Url $cth -Interactive

Add-PnPContentType -Name "IT Template Document" -ContentTypeId "0x0101001611568CC163BF408A2B9341656A02290701" -Group "MyGroup" 

Once you’ve recreated the Content Type with the same name Name and Id, you can publish it and then unpublish it to get rid of the orphans.

The modern Content Type Gallery is a bit smarter. If you delete a Content Type from there, you’ll get this message, which basically says the Content Type – if published – will be unpublished before it is deleted. No more orphans! This is a good example why you should stop using the classic UI for the Content Type Hub.

Resources

How to Unpublish Orphaned Content Types in SharePoint, Script Provided (collabware.com) – Osama Khan

Add a Location Column to a Site Content Type

Have I ever mentioned how important Content Types are in SharePoint? Almost everything you work with in SharePoint has a Content Type. If you’re just using Document and Item, you’re really not using the platforms.

In this post, I want to talk about Site Content Types and the Location column type.

Location Columns

Sometime in the last few years, we got a cool new type of column we can use in SharePoint. In Microsoft’s infinite wisdom, it’s called either a GeoLocation column or a Location column, depending on where you interact with it. It’s got a lot of magical qualities, but I can’t easily find an end user article about those qualities. Buried in the support article List and library column types and options, you’ll read this:

Add rich location data from Bing Maps or your organization directory. The location column provides additional columns to filter, sort, and search by related information including street address, city, state, country or region, postal code, coordinates, or name.

Site Content Types

Site Content Types are the best kind of Content Types in my book because we can instantiate them across modern sites with Site Templates (nee Site Designs).

Until recently, we couldn’t create a Location column as a Site Column (to add to a Site Content Type) unless we ran the Add-PnPField PnP.PowerShell cmdlet. (See: Add a Geolocation column to a list programmatically in SharePoint) Not exactly the purview of your average information architect.

Today I wondered if this had changed – and it has!

Add a Location Column to a Site Content Type

The big thing that changed recently is that Microsoft is slooowwwlyyy moving us away from the Content Type Hub and into the Content Type Gallery. When the new Content Type Gallery was initially delivered, it was really just lipstick on a pig; it was still the Content Type Hub underneath.

Now when we go into Site Settings on a modern site and click the Site content types link, we land in the Content Type Gallery. This is pretty new, and it’s possible you don’t see it in your tenant yet, though it seems to be in all the tenants where I’m working. In the Content Type Gallery , we can add Site Columns in this new UI with the Location column type.

Let’s say I want to create a Site Content Type called Property. A very normal thing I’d want to know about a Property is its address, and I’d sure like to use a magical Location column type to capture it. Here’s the sequence.

From the home page of your modern site:

Click on the gear

Choose Site information, then View all site settings

On the ugly old Site Settings page, we still see the same old two options in the Web Designer Galleries section:

The difference is now when we click on the Site content types link, we land in the Content Type Gallery.

Once we’re here, we can build the Content Type pretty much like we would in the old UI. It’s basically the same.

The big difference for this post is we can now choose a Location column when we create a new Site Column.

See that Location in the Type column below?

When we go back to the site, we have the Location column, and it’s set up as a Site Column, so we can reuse it, maybe promote it to a Managed Property for search (though I haven’t done this), etc. Even better, we can package up that Property Content Type into a Site Template so we can instantiate it in new sites where we want the same information architecture. This latter step will require some PowerShell, and maybe you shouldn’t run with those scissors. Find a SharePoint Admin to help here.

I did run into one issue. I had already enabled the Property Content Type in a list, and the new Location column wasn’t showing up. Unfortunately, the Update sites and lists option, which we’re used to having checked by default is now NOT checked by default. So you need to be sure to click it EVERY TIME YOU MAKE A CHANGE TO THE CONTENT TYPE if you want that change to cascade down into your list or libraries. I have never unchecked that box in the past, and I consider it a “bug” that the default is unchecked now. At least it’s something we can work around. I hope Microsoft changes this back to the old behavior.

❌
❌