pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
985 stars 665 forks source link

Add-PnPClientSideWebPart : adding List webpart fails with "Object reference not set to an instance of an object error". #2937

Closed adzero closed 3 years ago

adzero commented 3 years ago

Reporting an Issue or Missing Feature

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.

Expected behavior

List WebPart should be added to the client side page.

Actual behavior

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

Steps to reproduce behavior

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

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.25.2009.1 (quickly tried the last "known" working version in production environment which was 3.18.2002.0, but also fails)

How did you install the PnP-PowerShell Cmdlets?

Ganesh-Rajagopal commented 3 years ago

Client Web Part Issue Am also getting the same issue. Please help us.

dev-a11y commented 3 years ago

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

Wit4r7 commented 3 years ago

Same problem for us. We developed a new experience for our colleagues, and now it is not working anymore with the same error.

jansenbe commented 3 years ago

The root cause of the problem has been found and a fix is rolling out soon.

jansenbe commented 3 years ago

Think we can close, there's many independent confirmations the issue is fixed