Provisioning Metadata Navigation using CSOM

Copper Contributor

Is it possible to enable Metadata Navigation for a list or libray using CSOM and preferably using PnP PowerShell or the PnP Provisioning framework ?

6 Replies

It does not appear to be currently possible with the pnp powershell cmdlets because a parameter for that setting is not availabe in the set-spolist cmdlet. @Erwin van Hunen should have some additional insight.

I thought it was not possible at this time. But you could always write a extention to do this.

This should be possible according to multiple pages found online, like this https://srinivasananand.wordpress.com/2015/10/29/activating-document-lib-tree-navigation-using-csom/...

 

However, I'm having the problem that the new settings do not automatically become visible in the List GUI. I first have to press Apply/OK in the metadata navigation settings (that shows my changes correctly) of the list  before I can see the keyfilters I've added in the list GUI.

 

Here's my script:

$list = Get-PnPList -Web $web -Identity $aListName -ErrorAction SilentlyContinue;

if ($list)
{
$prop = Get-PnPProperty -ClientObject $list -Property 'RootFolder';
$aRootFolder = $list.RootFolder;

$prop2 = Get-PnPProperty -ClientObject $aRootFolder -Property 'Properties';

$aRootFolder.Properties["client_MOSS_MetadataNavigationSettings"] = "bunch of correct XML";
$aRootFolder.Update();
$list.Update();
$web.Context.ExecuteQuery();
}

I have the same problem. Have you ever managed to solve this ?

Did you enable the Metadata Navigation Feature on the web prior to setting the Property bag? I was able to set the filter fields, without user intervention, using the following PowerShell script:

 

Enable-PnPFeature -Identity "7201d6a4-a5d3-49a1-8c19-19c4bac6e668" -Scope Web
$list = Get-PnPList "Documents"
$fld = Get-PnPProperty -ClientObject $list -Property "RootFolder"
$props = Get-PnPProperty -ClientObject $fld -Property "Properties"
$props["client_MOSS_MetadataNavigationSettings"] = '<MetadataNavigationSettings SchemaVersion="1" IsEnabled="True" AutoIndex="True">(with contents copied from a correctly configured folder...)</MetadataNavigationSettings>'
$fld.Update()
$list.Update()
$list.Context.ExecuteQuery()