pnp / PnP-Provisioning-Schema

Office 365 Patterns and Practices - Remote Provisioning Schema
MIT License
161 stars 220 forks source link

Unable to set List View when provisioning client side page List View webpart #414

Open gallantdon opened 4 years ago

gallantdon commented 4 years ago

I am attempting to provision a client side page with multiple list view webparts. I extracted the provisioning template and then moved it to a another file that will be used for the site provisioning. I am able to get all the webparts on the page, but they all have the default view and the ViewID is not set correctly. Below shows both ways that I have attempted to reference the list view.

`

`
marineko commented 4 years ago

I have experienced same issue. In my case, I extracted provisioning template following command, and apply it to another site.

Get-PnPProvisioningTemplate -Out template.xml -IncludeAllClientSidePages

Clientside pages and list web parts on the page were created properly, but view settings were incorrect.They all get back to default view. the only work around I found is to change web part property via following powershell.

$view =  Get-PnPView -List [List Name] -Identity [View Name]

$contents = Get-PnPClientSideComponent -Page [Page Name] # get all web parts on page.
$myproperties = $contents[1].PropertiesJson #Identify list web part by index and get web part property.
$col = $myproperties |  ConvertFrom-Json
$col.selectedViewId = $view.Id
$myproperties = $col | ConvertTo-Json
Set-PnPClientSideWebPart -Page [Page Name] -Identity $contents[1].InstanceId -PropertiesJson $myproperties 

It may be hard to correct view settings one by one if you have many web parts. I hope this issue will be fixed and view setting be provisioned correctly.

wspelt commented 4 years ago

I have experienced this issue in maybe a different way. Initially it seems to set the view correctly most of the times on the clientside webpart. However sometimes it switches back to the old default view. This is the code I use:

wspelt commented 3 years ago

Hi, has this issue already been resolved? As a workaround I also reset the selectedViewId again after the PnP provisioning template has finished.

gallantdon commented 3 years ago

@wspelt I am not sure if the issue was addressed with a version release. I was on a timeline when I posted this so I set it manually and moved one. I appreciate the response though.