When using Add-PnPClientSideWebPart to add a List webpart to a page, it fails and display a _Object reference not set to an instance of an object_ error.
List WebPart should be added to the client side page.
Webpart is not added to the page and the command fails with _Object reference not set to an instance of an object_ error.
Here's the output of my real script :
Add-PnPClientSideWebPart : Object reference not set to an instance of an object.
At Line 1, char:1
+ Add-PnPClientSideWebPart -Page $testPage -Section 1 -Order 1 -Column ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPClientSideWebPart], NullReferenceException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.WebParts.AddClientSideWebPart
Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/example-site
$web = Get-PnPWeb
$documentsList = Get-PnPList -Identity Documents -Includes DefaultView
$testPage = Add-PnPClientSidePage -Name TestPage -LayoutType Article -CommentsEnabled:$false -Publish -HeaderLayoutType NoImage -PromoteAs None
Add-PnPClientSidePageSection -Page $testPage -SectionTemplate OneColumn -Order 1 -ZoneEmphasis 0
$webPartProperties = @{"selectedListId" = "$($documentsList.Id)";"selectedListUrl" = "$($documentsList.RootFolder.ServerRelativeUrl)";"webRelativeListUrl" = "$($documentsList.RootFolder.ServerRelativeUrl -ireplace $web.ServerRelativeUrl,"""")";"selectedViewId" = "$($documentsList.DefaultView.Id)";"webpartHeightKey" = 1;"isDocumentLibrary" = $true}
Add-PnPClientSideWebPart -Page $testPage -Section 1 -Order 1 -Column 1 -DefaultWebPartType List -WebPartProperties $webPartProperties
3.25.2009.1 (quickly tried the last "known" working version in production environment
which was 3.18.2002.0, but also fails)
Am also getting the same issue. Please help us.
same for us, looks like not related to pnp engine (we have not upgraded it for almost a year); on our tenant the issue started this week, all our newly provisioned pages are missing list webparts - ughh
Same problem for us. We developed a new experience for our colleagues, and now it is not working anymore with the same error.
The root cause of the problem has been found and a fix is rolling out soon.
Think we can close, there's many independent confirmations the issue is fixed
Most helpful comment
The root cause of the problem has been found and a fix is rolling out soon.