Expiring News across Modern SharePoint

Reading Time: 6 minutes

The new modern web parts rolling out to SharePoint right now are fantastic and getting better every day.  One of the ways modern web parts can be used is to build modern pages for sharing news across an organization. A common requirement for organizational news is to have an expiry date associated with each one. Although you can allow old news to just roll off the view as more recent news is published in its place (and this is a perfectly legitimate option), sometimes you don’t want expired news to show after it expires. I was recently asked if this is possible. It turns out it is and in fact there’s more than 1 way to do it using Modern Pages and search with the Highlighted Content web part. The option you choose depends on where you want your news items to show!

Option 1: Use a Page Property on the Site Pages library, and filter on the Page Property expiry date being after today. Using this technique, you can display non-expired news pages on the site, however sorting by expiry date is not allowed and you cannot filter these pages on another site, including a Hub.

Option 2 (my preferred): Use a site column as a Page Property on the Site Pages library, and filter based on the managed property associated to the Page Property where it’s after today. Using this technique, sorting by the expiry IS allowed so those pages expiring first will show at the top of the list, and you can also filter these pages by expiry date on any other site in the tenant (permissions permitting), including a Hub. See why I prefer this option? 🙂

Limitation for BOTH options: as of the time of this writing, all filters in the Highlighted Content Web Part are OR’d together which means you can’t have multiple combined conditions to limit your results. For this reason, you can’t filter on two properties of the Site Pages library if you had a requirement to do so. Also, this solution will exclude pages with NO expiry date. I’ve made this work for me as the home page and all summary pages have no expiry date – only news pages will have an expiry date added.

[Update February 7, 2019] This solution was built using Modern Communication sites. If you are using Modern Team sites with a Group for this solution, ensure your userid is explicitly identified as a site collection administrator on the site for Option 2 – it’s not enough to be in the Owners group. This is so managed properties will be created in the search schema, a requirement for Option 2. Please refer to another blog post where I explain this current Modern Team site behavior – Crawled & Managed Properties in Modern Team Sites.

Option 1 steps:

Step 1: Add the Page Property to the Site Pages library. To do this, browse to the library settings and add a column to the library (can be either a list or existing site column). For this example, I added 1 date column called ExpiryDate.

Step 2: Add some pages to the Site Pages library. Make sure you have a mixture of expired and non-expired pages by setting an expiry date accordingly. Publish each page.

Step 3: Add another modern page to summarize the Non-Expired news pages (don’t put an expiry date value on this page). Add a Highlighted Content Web Part with the following settings and filter:

You’ll notice with this option, you cannot sort by the ExpiryDate custom page property. Only 4 out-of-the-box options are allowed (Most recent, Author, Name, Title):

The Site Pages library for this test looks like this. The 2 pages with the green check marks are what I expect to appear on the summarized News page based on today’s date of January 25, 2019:

Here’s what the Summarized-News page looks like, as expected:

Option 2 Steps:

Step 1: Create a date site column called ExpirationDate. (it must be a site column and not just a list column)

Step 2: Add the above site column to the Site Pages library.

Step 3: Add some pages to the Site Pages library. Make sure you have a mixture of expired and non-expired pages by setting the expiry date accordingly. Publish each page.

Step 4: Wait a period of time for the above pages to be crawled by the search engine (~15 minutes). We need to associate a managed property with the ExpirationDate crawled property created from the site column above. This is done in the search schema at either the tenant or site collection level. In this example, the mapping was done at the tenant level so it can be shared across all sites in the tenant.

  • In the SharePoint Admin Center, click SearchManage Search Schema
  • View managed properties and search for RefinableDate
  • Pick any unmapped RefinableDate## managed property (if you’ve never mapped one before, none of them will be mapped so select the first one, RefinableDate00, as I’ve done in my example)
  • Edit/Map the RefinableDate## managed property to the crawled property automatically generated for the ExpirationDate column, in my case ows_q_DATE_ExpirationDate. The alias name is optional.

Note: important to understand with the RefinableDate## managed properties are the settings that are enabled for it. This is what allows us to filter and sort by the property in the highlighted content web part and why we need to do this mapping.

Now that the managed property is configured, we can start filtering our news pages! It may take a few minutes for the mapping to be seen back down in your site with the news pages.

Step 5: Add another modern page to summarize the Non-Expired news pages (don’t put an expiry date value on this page). Add a Highlighted Content Web Part with the following settings and filter based on the RefinableDate00 managed property we mapped above in Step 4:

You’ll notice with this option, we can now sort by the ExpirationDate custom page property that is mapped to RefinableDate00.

Step 6: The Site Pages library for Option 2 looks like this. The 2 pages with the green check marks are what I expect to appear on the summarized News page based on today’s date of January 25, 2019:
… and as expected, here’s what the Summarized-News page looks like. Note the pages are displayed in ascending order by ExpirationDate:

Show it on the Hub (or any other site)

With Option 2 only, we also have the ability to show this filtered set of pages on any other site in the tenant, including a SharePoint Hub. This is why the managed property option is a scalable approach.

A practical use-case for this would be divisional news sites all joined to a corporate hub. Each divisional site would have the ExpirationDate site column defined and set on their news pages. At the Hub level, a Highlighted Content Web Part can look to all sites joined to the Hub and filter/sort based on the same managed property. In this image, we’re filtering all non-expired news pages from across all sites joined to the Hub. Awesome! 

To demonstrate this, in the image below, there are 2 Division sites joined to the Corporate News Hub (Division and Division 2). There are 4 non-expired news pages showing in the Highlighted Content Web Part from the 2 sites (yellow and blue stars) and the combined results are sorted in Expiration Date ascending order. What a smart use of search!

My thoughts…

As time goes on, additional capabilities will be introduced to the Highlighted Content web part to filter content to meet more complex requirements. It still has a long way to go before it has the flexibility and configurability the Classic search web parts currently have, however there are many features of the modern web part I love better: responsive design, great out-of-the-box visuals, and easier for a Power User to configure. I’m looking forward to the advancements being made to the modern search web part… until then, learn how to leverage the current capabilities and incrementally build upon them as new ones are added.

Thanks for reading. 🙂

-JCK


Would you like to connect with me to ask questions, use me as a thinking partner, request feedback, learn more about what I do, or learn more about what I can do for you? That’s great! I’d love to connect and find out more about how I can support you in anyway. Book a call with me on Pick My Brain!

4 comments

  1. You don’t need to access the SharePoint Admin Center. Site collection admins can do it from the site settings page.

Leave a Reply

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