Set Global Nav in CSOM

I’ve been writing a client side object model script to set up some sites, including setting some the navigation settings on the site. Sadly, Microsoft have written SharePoint to involve at least 3 objects in the navigation settings for a site (PublishingWeb, WebNavigationSettings, and SPNavigation. At least. It’s totally effing bonkers.), and those objects don’t work in quite the same way for CSOM. For example, it’s not clear how to set a site to ‘show subsites’ in the global navigation.

Fortunately, Bex Gordon has an example – in short, set the property through the AllProperties:

web.AllProperties["__GlobalNavigationIncludeTypes"] = ...

The same works for "__CurrentNavigationIncludeTypes" too. Values are 0-3 – a bit mask. The first bit is for Show Subsites, the second is Show Pages.

Some other settings such as the maximum number of dynamic items to show, etc., can set in a similar fashion. Ugly, but works – which is more than can be said for the API…

Set Global Nav in CSOM

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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