Add-PnPNavigationNode in a Hub Site requires manual refresh #2021
Comments
I remember reading something about the hub navigation being cached. Editing the entries maybe invalidates the cache. But I don't know details or how to clear this. But as you say - the API used in the UI looks different from the "classic" SharePoint API. So maybe this is just a bug in the backend. |
I was able to reach out to Vesa Juvonen and he confirmed that the navigation is indeed being cached. I did a few tests and found that it seemed to be refreshed between 30 and 60 minutes but that's just a guess since I'm sure many factors affect the timing. I might be able to invoke /_api/navigation/SaveMenuState to force a refresh but for my needs the wait for the cache to refresh on it's own is perfectly acceptable. |
It would be nice to be able to force a refresh. It took about an hour for my mega menu to refresh after updating it with PowerShell. Auto-site provisioning with navigation is being delayed by the inability to perform a refresh. |
@bogeorge I don't suppose you can share the comms you had with Vesa please? We've got a vendor that's struggling to justify a specific tenant that is taking ~4 hours to refresh hub navigation items. |
Hey @nateforsyth, Really the main thing I got from Vesa was confirmation that the navigation would refresh from cache on a schedule (typically after 30-60 minutes). I would assume that time could be variable so they may extend that time frame if it's causing too much load or maybe now that Office 365 volume has increased so much. I noticed that when you edit the nav via the UI it updates right away in my experience so the delay only seems to be related to programmatic updates. In our case we sync navigation from one site to several hubs programmatically in an Azure Function. We have this run on a schedule nightly and so far this has allowed there to be enough time for all the affected hubs to refresh before anyone can get worried. |
###Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:###
Apply-SPOProvisioningTemplate
orGet-SPOProvisioningTemplate
? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.Reporting an Issue or Missing Feature
Reporting an issue (or asking a question :))
I first noticed the issue with Apply-PnPProvisioningTemplate but have tried to isolate to the most simplistic example to see what I'm missing or doing wrong.
I'm connected using Connect-PnPOnline to a Hub Site that is set to use the new MegaNav style navigation. I execute the command below
Add-PnPNavigationNode -Location TopNavigationBar -Title "test" -Url "http://www.google.com"
Expected behavior
The node is successfully added to the navigation and it is refreshed.
Actual behavior
The node is successfully added to the navigation but the navigation is not "refreshed". Clicked Edit Nav and then closing without saving makes the new node show.
Steps to reproduce behavior
Use Connect-PnPOnline to connect to a site collection that is both a Hub Site and configured with MegaNav for the navigation
Execute Add-PnpNavigationNode to add a new node to the top navigation bar
for example:
Add-PnPNavigationNode -Location TopNavigationBar -Title "test" -Url "http://www.google.com"
I realize MegaNav is very new, especially when combined with the site being a Hub Site. I'm wondering if there are other calls I need to make to force it to refresh.
Using developer tools I see these api's invoked when you open the nav and close, maybe I can try calling the SaveMenuState but I'll need to generate the object it expects.
/_api/navigation/SaveMenuState
/_api/navigation/menustate
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
(you can retrieve this by executing
Get-Module -Name *pnppowershell* -ListAvailable
)How did you install the PnP-PowerShell Cmdlets?
The text was updated successfully, but these errors were encountered: