Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gallantdon opened this issue Jul 24, 2019 · 4 comments

Comments

@gallantdon
Copy link

gallantdon commented Jul 24, 2019

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.

` pnp:ClientSidePages
<pnp:ClientSidePage PageName="My-Page.aspx" PromoteAsNewsArticle="false" Overwrite="true" Title="My Page" Layout="Article">
pnp:Sections
<pnp:Section Order="1" Type="TwoColumn">
pnp:Controls
<pnp:CanvasControl WebPartType="List" JsonControlData="{"id": "f92bf067-bc19-489e-a556-7fe95f508720", "instanceId": "8ac227a7-6928-4adb-8748-f7624c03031e", "properties": {"isDocumentLibrary":false,"selectedListId":"{listid:Pins}","selectedListUrl":"{site}/Lists/Pins","webRelativeListUrl":"/Lists/Pins","webpartHeightKey":1,"selectedViewId":"9438a1f3-b15d-40fe-955f-6aff47a9e001","hideCommandBar":true}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"listTitle":"My Pins"},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="f92bf067-bc19-489e-a556-7fe95f508720" Order="1" Column="1" />
<pnp:CanvasControl WebPartType="List" JsonControlData="{"id": "f92bf067-bc19-489e-a556-7fe95f508720", "instanceId": "0c50b82a-d0de-424d-8502-a23252bdf42f", "title": "List", "description": "Add a list", "dataVersion": "1.0", "properties": {"isDocumentLibrary":false,"selectedListId":"{listid:Pins}","selectedListUrl":"{site}/Lists/Pins","webRelativeListUrl":"/Lists/Pins","webpartHeightKey":1,"selectedViewId":"{9438a1f3-b15d-40fe-955f-6aff47a9e002}","selectedFolderPath":"","hideCommandBar":true}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"listTitle":"My Apps"},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="f92bf067-bc19-489e-a556-7fe95f508720" Order="1" Column="2" />
</pnp:Controls>
</pnp:Section>
<pnp:Section Order="2" Type="TwoColumn">
pnp:Controls
<pnp:CanvasControl WebPartType="List" JsonControlData="{"id": "f92bf067-bc19-489e-a556-7fe95f508720", "instanceId": "b5646250-06fb-4dcc-96e1-bfdf839b4686", "title": "List", "description": "Add a list", "dataVersion": "1.0", "properties": {"isDocumentLibrary":false,"selectedListId":"{listid:Districts &amp; Divisions}","selectedListUrl":"{site}/Lists/DistrictsAndDivisions","webRelativeListUrl":"/Lists/DistrictsAndDivisions","webpartHeightKey":1,"selectedViewId":"{9438a1f3-b15d-40fe-955f-6aff47a9ea02}","showDefaultDocumentLibrary":false,"hideCommandBar":true}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"listTitle":"Districts & Divisions"},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="f92bf067-bc19-489e-a556-7fe95f508720" Order="1" Column="1" />
<pnp:CanvasControl WebPartType="List" JsonControlData="{"id": "f92bf067-bc19-489e-a556-7fe95f508720", "instanceId": "bc535e48-f5b3-4af6-82df-9d55c305d7b9", "title": "List", "description": "Add a list", "dataVersion": "1.0", "properties": {"isDocumentLibrary":false,"selectedListId":"{listid:Communities}","selectedListUrl":"{site}/Lists/Communities","webRelativeListUrl":"/Lists/Communities","webpartHeightKey":1,"selectedViewId":"{9438a1f3-b15d-40fe-955f-6aff47a9ea02}","hideCommandBar":true}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"listTitle":"Communities"},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}" ControlId="f92bf067-bc19-489e-a556-7fe95f508720" Order="1" Column="2" />
</pnp:Controls>
</pnp:Section>
<pnp:Section Order="3" Type="TwoColumn">
pnp:Controls
<pnp:CanvasControl WebPartType="Custom" ControlId="1b1daffd-427a-4da8-a6dd-823d62b5725a" Order="1" Column="1" />
</pnp:Controls>
</pnp:Section>
</pnp:Sections>

</pnp:ClientSidePage>  

</pnp:ClientSidePages>`

@marineko
Copy link

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
Copy link

wspelt commented Apr 21, 2020

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:

<pnp:CanvasControl WebPartType="List" JsonControlData="{ "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "properties": {"isDocumentLibrary":true,"selectedListId":"{listid:Documenten}","listTitle":"Documenten","selectedListUrl":"{listurl:Documenten}","webRelativeListUrl":"/Gedeelde documenten","webpartHeightKey":2,"selectedViewId":"{viewid:Documenten,Documenten overview}"}}" ControlId="f92bf067-bc19-489e-a556-7fe95f508720" Order="1" Column="2" />

@wspelt
Copy link

wspelt commented Jan 6, 2021

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

@gallantdon
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants