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!

12 comments

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

  2. Hi Joanne, Thanks for this great article. I am following your steps for option 2 in a hub and associated sites configuration for my organisation news. I have setup the site column “Expiration Date” at all sites associated to the hub and added them to the pages library on each site. But, when I go to the Search Schema in Admin center, I cannot find the crawled property of the “Expiration Date”. I have waited for over 4 hours for the search to crawl. Can you please tell me what I should do? Thanks in advance!

    1. Hi MT, make sure you actually have at least one site page where you’ve put in a value for the Expiration date and publish the page. Only then will a crawled property get created. Hope that helps.
      -JCK

  3. Hi Joanne,
    Have you had any updates to this article or can point to any changes from what you detailed?
    Surprised that it is taking this long for MSFT get the expiry capability done and dusterd; it is central to all publishing.
    Thanks
    Russell

  4. hi, thanks a lot for a great and helpful article. Please tell me what I should if i want to article will be visible even when the expiration date column is empty??

  5. We have followed the steps using the first method (for our Home Site’s Site Pages library) and it’s not working. Wondering if it’s because the home site is a Hub, and also designated as an Organization News site?

  6. Can method 2 be used with multiple properties using a caml query instead of the GUI selector?
    I’m not familiar with CAML and can’t seem to write it but this is what I want to do:
    Property 1: Hub site location
    Property 2: Expiry Date

    So each Hub site can have content highlighted from other hub sites by simply setting say “HOME” as location and a future date in Expiry.

    If anyone can help me with the CAML query for the Highlighted Content web part i’d be happy to test.

  7. Hi, great article. I have configured for multiple sites and was wondering do I need to update the refinableDate.
    Do I need to map multiple expiration dates (1 for each hub site)

Leave a Reply to Rachel DavisCancel reply

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