Vue normale

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

Filtering SharePoint News Pages with Metadata

This is a quick tip about a SNAFU which caught me up today. I got to do a “Doh!” in front of a client, which is always fun. Hopefully this will save you the same embarrassment.

Home Simpson saying "Doh!"

Filtering News pages based on some metadata applied to the pages is a thing, and has been for a good, long time. I knew it should work, and pretty easily at that.

When I was on the call, I had added a metadata column to the Site Pages library. Simple. I went and put the page with the News Web Part into edit mode and looked in the Filter section for Page properties. No joy. Instead I was seeing:

Managed Properties are awesome, and I set them up all the time so I can build search-driven solutions, usually with the PnP Modern Search Web Parts, which, as I’ve said before, are the bees knees. But I knew there should be an option to filter based on Page properties instead. Had something changed? Was it better? I wasn’t sure.

I fired up my MVP communication channel and asked if things had indeed changed. As I expected, Susan Hanley (@susanhanley) responded almost right away.

Look to see what the Source is for News. When it is a single site (i.e., the site you are on), you can filter using Page properties. When you are selecting news from multiple sites, you will not see the Page Properties option – just Managed property.

Doh! I hadn’t even though to check that setting! A simple change at the top of the News Web Part properties to use This site as the source, and Page properties was back where I expected it.

This makes sense if you think about it. The Page properties in Site Pages libraries probably wouldn’t be consistent across multiple sites, so Managed properties makes more sense. Within one site, the Site Pages library is a single source, so has to be consistent with itself.

I do think there could be some in-Web-Part assistance for this with a slightly better UI, though. Maybe just an info bubble like the Enable audience targeting section right below it?


As you might expect, Greg Zelfond (@gregoryzelfond) has a great post about all this if you want to understand it better:

How to manage categories of news using custom metadata – SharePoint Maven

Crawled Properties Not Created From Site Columns in Modern Team Sites

You know that feeling where you’ve done something so many times and it’s worked and then one day it just doesn’t? Yeah, I just had one of those.

I’m still a big fan of the PnP Modern Search Web Parts, just like I was last week or last year. To really make them sing in your solutions, you’ll end up creating Site Columns and using Content Types. I love those things, too, but this post isn’t about why.

Over the last few weeks, when I have created Site Columns, made sure they are included in Content Types, and added content using those Content Types, the Site Columns have not shown up as Crawled Properties in the SharePoint Admin Center (More features / Search [Open] / Manage Search Schema). They simply never show up. I’ve given it overnight, then a week, then two weeks.

The sequence here is important, so to reiterate:

  • Create your Site Columns
  • Add the Site Columns to Content Types
  • Add content using those Content Types – This is the one that bites many people, including me. No content, nothing to crawl!
  • The Site Columns show up as Crawled Properties

I swear this has been a reliable way to go from Site Columns to Managed Properties (after mapping to Refinable[Type]NN Managed Properties) for years. The ultimate goal in my case is to use those Managed Properties in search-driven solutions using the PnP Modern Search Web Parts. But of course, Managed Properties have other benefits as well.

I’ve been doing this for years, and I sorta feel like I know what I’m doing. I’m not proud, so I headed over to my MVP channels, and tagged people like Agnes Molnar (@molnaragnes) and Mikael Svenson (@mikaelsvenson) in a post asking whether something had changed.

Agnes pointed out an old post from Joanne Klein (@JoanneCKlein) entitled Crawled & Managed Properties in Modern Team Sites. Turns out there’s a kooky hole in things. I have no idea why this hasn’t gotten in my way before.

If you are creating your IA (my shorthand from Site Columns and Content Types, among other things) in a modern Team Site, it’s not good enough to be an Owner. As Joanne wrote, you also need to add yourself as a Site Collection Administrator directly. (Site Permissions / Advanced permissions settings / Site Collection Administrators)

Event though you’re in the Owners group, and the Owners group is in the Site Collection Administrators, you still need to add yourself directly.

Do that, kick off a re-index of the site in question, and within moments practically, your Crawled Properties will be ready to use. None of us are quite sure why this is, but it worked in two tenants for me today, one right after the other.


In case you’re wondering, once you have the Crawled Properties in place (below, ows_SiteName, ows_ExaminerName, and ows_Jurisdiction are Crawled Properties), you can map them to Managed Properties (RefinableString00, RefinableString01, and RefinableString02 below). Those Managed Properties can then be used as filters (nee refiners) in the PnP Modern Search Web Parts or elsewhere.


Mikael also pointed me to his post Tech and me: Mapping or clearing crawled property to managed property mappings using PowerShell (or code). This looks like it might help with this problem, but more likely is most useful when the Crawled Properties are not showing due to a different bug.

Thank you Joanne, Agnes, and Mikael!

❌
❌