From 0ea1c82c04342754a64881f5c6b01f8ba579efbf Mon Sep 17 00:00:00 2001 From: Bert Jansen Date: Wed, 10 Jan 2024 18:22:32 +0100 Subject: [PATCH] Viva Announcement Library resulted in two `pages` libaries breaking the page library detection logic #1343 --- src/sdk/CHANGELOG.md | 1 + .../Model/SharePoint/Pages/Internal/Page.cs | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/sdk/CHANGELOG.md b/src/sdk/CHANGELOG.md index 3cc5a47234..21416a581f 100644 --- a/src/sdk/CHANGELOG.md +++ b/src/sdk/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Admin library: added support to specify the timezone when creating a site collection #1334 [kfircs - Kfir Chen] - Auth library: default access token retrieval log message to `debug` instead of `information` #1328 [jansenbe - Bert Jansen] +- Viva Announcement Library resulted in two `pages` libaries breaking the page library detection logic #1343 [jansenbe - Bert Jansen] ## [1.11.0] diff --git a/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs b/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs index 0ff9b16adc..ceabe60135 100644 --- a/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs +++ b/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs @@ -485,11 +485,18 @@ private static async Task EnsurePagesLibraryAsync(PnPContext context) // The site pages library has the CanvasContent1 column, using that to distinguish between Site Pages and other wiki page libraries if (list.IsPropertyAvailable(p => p.Fields) && list.Fields.AsRequested().FirstOrDefault(p => p.InternalName == "CanvasContent1") != null) { - if (list.ArePropertiesAvailable(getPagesLibraryExpression)) + // Verify this is the "real" pages library, sites supporting Viva Connections have a second pages library (named Announcements) used to + // store Viva Connections announcements + if (list.IsPropertyAvailable(p => p.ListItemEntityTypeFullName) && list.ListItemEntityTypeFullName == "SP.Data.SitePagesItem") { - pagesLibrary = list; + if (list.ArePropertiesAvailable(getPagesLibraryExpression)) + { + pagesLibrary = list; + } + + // As there's only one real pages library we can bail out now + break; } - break; } } } @@ -510,7 +517,11 @@ private static async Task EnsurePagesLibraryAsync(PnPContext context) { foreach (var list in libraries) { - if (list.IsPropertyAvailable(p => p.Fields) && list.Fields.AsRequested().FirstOrDefault(p => p.InternalName == "CanvasContent1") != null) + if (list.IsPropertyAvailable(p => p.Fields) && + list.Fields.AsRequested().FirstOrDefault(p => p.InternalName == "CanvasContent1") != null && + // Verify this is the "real" pages library, sites supporting Viva Connections have a second pages library (named Announcements) used to + // store Viva Connections announcements + list.ListItemEntityTypeFullName == "SP.Data.SitePagesItem") { pagesLibrary = list; break;