Krzysztof Pintscher
written by Krzysztof Pintscher
posted on January 17, 2023
In Salesforce world since 2014. In the Middle Ages I was an Aura Knight. These days I'm just a LWC cowboy.
Table of Content

Having troubles with Navigation Menus after Spring ’23 update?

<Obi-Wan voice>Hello there!</Obi-Wan voice>

Why are you here?

I'm guessing you were Googling an issue which affected some of us - and probably you were affected too - the release update known as "Apply User Access Permissions to Navigation Menus Retrieved by Apex in Experience Cloud Sites". This almighty Release Update was introduced with Winter '23 and enforced with Spring '23 release. You've probably missed that with Winter '23 and got slapped in your face with the bug from QA team: "missing menu items" - in your Community.

What is the problem?

I'm not sure, probably is one of those "Salesforce things" - which sometimes happens.
Long story short: menu items of InternalLink were missing from response and somehow, magically, disappeared over the weekend from our Experience Site.

Ok, enough, is there any fix?

Yeah, actually two - depeneds how you want to retrieve your Navigation Menu Items or what are you doing with those records.


You can use ConnectApi - described here.

public static ConnectApi.NavigationMenuItemCollection getCommunityNavigationMenu(String communityId, String navigationLinkSetId, String navigationLinkSetDeveloperName, ConnectApi.PublishStatus publishStatus, Boolean includeImageUrl, Boolean addHomeMenuItem, List<ConnectApi.NavigationMenuItemType> menuItemTypesToSkip)

As far as I've checked - it was working fine - and Salesforce shows it as a code sample over here. Just download the zip file and check NavigationMenuItemsController.

Downside of this solutions is fact that it uses structure created by SF.
But what if you don't want this structure of Navigation Menu Items?

H4cker fix

I'm just joking, there won't be any hacking - that's the "Salesforce things" part.

You are probably querying your NavigationMenuItem by NavigationLinkSet.DeveloperName or NavigationLinkSet.MasterLabel - or somehow similar, so your query looks like:

return [
    SELECT Id, toLabel(Label), Type, Target, Position, ParentId, DefaultListViewId, TargetPrefs, Status
    FROM NavigationMenuItem
    WHERE NavigationLinkSet.DeveloperName = :navigationLinkSetDevName AND Status = 'Live'
    ORDER BY ParentId, Position

It's not gonna work - not for today anyway (today === 17 Jan 2023), but there's a simple fix! You will have to query your NavigationMenuItem by NavigationLinkSetId! Yeah, that simple!

List<NavigationLinkSet> linkSets = [
    FROM NavigationLinkSet
    WHERE DeveloperName = :navigationLinkSetDevName
    LIMIT 1

Id navigationLinkSetId = linkSets.get(0).Id;

return [
    SELECT Id, toLabel(Label), Type, Target, Position, ParentId, DefaultListViewId, TargetPrefs, Status
    FROM NavigationMenuItem
    WHERE NavigationLinkSetId = :navigationLinkSetId AND Status = 'Live'
    ORDER BY ParentId, Position

Of course you should make this code better - you should check if the NavigationLinkSet exists etc., but this is just a snippet which should help you out.


There is none. We, as developers, just have to start using "test runs" with Release Updates more often - to catch those kind of problems in a better manner.