Adding visual webpart to list display form

%3CLINGO-SUB%20id%3D%22lingo-sub-72480%22%20slang%3D%22en-US%22%3EAdding%20visual%20webpart%20to%20list%20display%20form%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-72480%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20working%20on%20creating%20a%20template%20for%20my%20SharePoint%202013%20site%2C%20using%20PNP%20powershell.%20%26nbsp%3BOne%20of%20the%20requests%20is%20to%20create%20a%20custom%20list%20and%20add%20a%20custom%20visual%20webpart%20to%20the%20display%20form.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EAdd-PnPWebPartToWebPartPage%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EServerRelativePageUrl%20%3C%2FSPAN%3E%3CSPAN%3E%22%2Fextranet%2Fanotherxcjlc%2Flists%2Fpleadings%2Fdispform.aspx%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EPath%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%22E%3A%5Cscripts%5CpnpSite%5CMLBDocumentUploader.webpart%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EZoneId%20%3C%2FSPAN%3E%3CSPAN%3E'Main'%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EZoneIndex%20%3C%2FSPAN%3E%3CSPAN%3E2%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20tried%20exporting%20the%20webpart%20from%20the%20display%20form%20and%20then%20adding%20it%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAdd-PnPWebPartToWebPartPage%20%3A%20Cannot%20import%20this%20Web%20Part.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20also%20tried%20downloading%20it%20from%20the%20webpart%20gallery%20and%20adding%20it%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAdd-PnPWebPartToWebPartPage%20%3A%20The%20operation%20could%20not%20be%20completed%20because%20the%20Web%20Part%20is%20not%20on%20this%20page.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWhat%20procedure%20should%20I%20use%20to%20add%20this%20webpart%20to%20my%20display%20forms%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThank%20you.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-72714%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20visual%20webpart%20to%20list%20display%20form%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-72714%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20feedback%2C%20I%20actually%20tried%20adding%20it%20to%20the%20webpart%20only%20page%20with%20the%20same%20errors.%20%26nbsp%3BI%20am%20thinking%20that%20add-webpart%20commandlet%20is%20not%20able%20to%20handle%20custom%20visual%20webparts.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-72642%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20visual%20webpart%20to%20list%20display%20form%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-72642%22%20slang%3D%22en-US%22%3E%3CP%3EHI%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F57008%22%20target%3D%22_blank%22%3E%40Sergei%20Gorelik%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20the%20issue%20that%20you%20are%20running%20into%20is%20similar%20to%20one%20I%20had%20a%20while%20back.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20case%20a%20view%20on%20a%20list%20was%20set%20to%20the%20default%20welcome%20page%20when%20I%20exported%20the%20site%20and%20PnP%20PowerShell%20wasn't%20able%20to%20handle%20the%20web%20parts%20on%20the%20page%20as%20the%20page%20used%20isn't%20a%20web%20part%20page%20but%20a%20view%20on%20a%20list.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wouldn't%20be%20surpised%20if%20you%20have%20the%20same%20issue%20as%20you%20are%20using%26nbsp%3B%3CSPAN%3EAdd-PnPWebPartToWebPartPage%20to%20add%20a%20web%20part%20to%20a%20page%20that%20isn't%20a%20web%20part%20page.%20You%20could%20probably%20add%20a%20new%20page%20and%20add%20a%20list%20view%20web%20part%20and%20then%20add%20your%20custom%20web%20parts%20to%20that%20page.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am working on creating a template for my SharePoint 2013 site, using PNP powershell.  One of the requests is to create a custom list and add a custom visual webpart to the display form.

 

I am using:

Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "/extranet/anotherxcjlc/lists/pleadings/dispform.aspx" -Path
"E:\scripts\pnpSite\MLBDocumentUploader.webpart" -ZoneId 'Main' -ZoneIndex 2
 
I tried exporting the webpart from the display form and then adding it:
Add-PnPWebPartToWebPartPage : Cannot import this Web Part.
 
I also tried downloading it from the webpart gallery and adding it:
Add-PnPWebPartToWebPartPage : The operation could not be completed because the Web Part is not on this page.
 
What procedure should I use to add this webpart to my display forms?
 
Thank you.
2 Replies

HI @Sergei Gorelik,

 

I think the issue that you are running into is similar to one I had a while back.

 

In my case a view on a list was set to the default welcome page when I exported the site and PnP PowerShell wasn't able to handle the web parts on the page as the page used isn't a web part page but a view on a list.

 

I wouldn't be surpised if you have the same issue as you are using Add-PnPWebPartToWebPartPage to add a web part to a page that isn't a web part page. You could probably add a new page and add a list view web part and then add your custom web parts to that page.

 

 

Hi @Pieter Veenstra

 

Thank you for your feedback, I actually tried adding it to the webpart only page with the same errors.  I am thinking that add-webpart commandlet is not able to handle custom visual webparts.