Forum Discussion
Provisioning Metadata Navigation using CSOM
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();
}
- Norman MannNov 16, 2017Copper Contributor
I have the same problem. Have you ever managed to solve this ?
- Jurgen WiersemaFeb 01, 2018Copper ContributorNope!
- Bart-Jan DekkerApr 30, 2018Copper Contributor
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()