powershell icon indicating copy to clipboard operation
powershell copied to clipboard

Error provisioning document set from provisioning template instance

Open peter-vranich opened this issue 3 years ago • 9 comments

Category

  • [x] Bug

This is an issue when using PowerShell 1.12.0 or Directly using PnP.Framework and PnP.Core 1.8.0 via C#

We have a site we use as a template for provisioning new sites. The template site has various content types, columns etc. configured for when a certain type of site is required. One of the content types for the template site is a custom Document Set content type, Custom Document Set. After provisioning a new site using either, PnP.PowerShell or via the C# libraries we are unable to create a new Custom Document Set in the newly provisioned site.

This is only an issue with PnP.PowerShell version 1.12.0 or PnP.Core 1.8.0. If I rollback PnP.PowerShell to 1.11.0 it all works fine and if I rollback to version 1.7.0 of the PnP.Core package in c# it all works fine as well. I had tried to just rollback to version 1.10.0 of the PnP.Framework and left PnP.Core as 1.8.0 but still had the error. When I rolled back to 1.7.0 of the PnP.Core package the error went away

Steps to reproduce

  1. Create a new site collection and configure a new Document set content type with some custom columns
  2. Add the content type to the default Document library
  3. Use PnP.PowerShell or c# to get the template instance
  4. Provision a new site collection and apply the template instance to the new site collection
  5. Navigate to the newly provisioned site and Document library and attempt to create a new custom document set

I am receiving the below error page when doing this

image

Expected behavior

After provisioning a new site based on the template site we are able to create new documents sets using the custom document set as per normal behavior and as per the template site

Environment details (development & target environment)

  • SDK version: 1.8.0
  • OS: Windows 11 for PowerShell and Azure function runtime 4
  • SDK used in: PowerShell script PnP.PowerShell 1.12.0 and azure function v4 and c# PnP.Framework 1.11.0 and PnP.Core 1.8.0
  • Framework: .NET 6.0 for the function app
  • Browser(s):
  • Tooling: VS Code for the PowerShell and Visual Studio Professional 2022

Thanks for your contribution! Sharing is caring.

peter-vranich avatar Dec 13 '22 01:12 peter-vranich

Hi all, I have noticed that failing Custom Document Sets have a different NewFormURL,

On working Custom Document Set, NewFormUrl : _layouts/15/NewDocSet.aspx

On failing Custom Document Set, NewFormUrl : _layouts/15/SPListForm.aspx?PageType=8

When running PnP.Powershell 1.12.0, in the template object created with Get-PnPSiteTemplate, the Custom Document Set content type has NewFormURL = '_layouts/15/NewDocSet.aspx'. However after applying the template to a site, the new Custom Document Set has NewFormURL = '_layouts/15/SPListForm.aspx?PageType=8'. I believe the error is occuring in Invoke-PnPSiteTemplate

CamHowarthInForm avatar Dec 13 '22 05:12 CamHowarthInForm

Hi @jansenbe,

I can see you moved this issue to pnp/powershel, but this is reproducible when not using PowerShell. I have an azure function purely running C# and we experience the same behavior as stated in the original entry above.

As far as we can see this is an issue when applying the template, regardless of whether we are using PowerShell or purely C#, as we can see that the NewForm URL is correct after getting the template instance but after we apply it to the destination site the NewForm URL is set /_layouts/15/SPListForm.aspx?PageType=8 instead of /_layouts/15/NewDocSet.aspx.

peter-vranich avatar Dec 13 '22 21:12 peter-vranich

@in-pv - Can you please update to the latest 2.1.x (if the issue is still there), however PS 7.2 or later is needed to benefit from all the bug fixes and improvements of that new release.

PS5 support has been dropped. Feel free to reopen in the appropriate repository if the issue persists. Thanks!

veronicageek avatar Apr 11 '23 16:04 veronicageek

Hi @veronicageek I can confirm that this still occurs with the PnP PowerShell version 2.1.1.

Can be reopened this issue or I have to create new one?

joaquinajenjo avatar Apr 25 '23 12:04 joaquinajenjo

@in-pv - From your original description it seems this doesn't happen only when using PnP PowerShell. Can you please open it in the appropriate repo (PnP Core or PnP Framework) which we are consuming. So when fixed, it'll also be in PnP PowerShell. Thank you.

veronicageek avatar Apr 25 '23 16:04 veronicageek

Ok. Thank You.

Meanwhile if someone has this issue can execute this patch to solve the error after applied the template (*replacing "MyDocSetContentTypeName" with your document set content type name)

$clientContext = Get-PnPContext $targetContentType = Get-PnPContentType -Identity "MyDocSetContentTypeName" $targetContentType.NewFormUrl = "_layouts/15/NewDocSet.aspx" $targetContentType.Update(1) $clientContext.ExecuteQuery()

joaquinajenjo avatar Apr 26 '23 10:04 joaquinajenjo

Ok. Thank You.

Meanwhile if someone has this issue can execute this patch to solve the error after applied the template (*replacing "MyDocSetContentTypeName" with your document set content type name)

$clientContext = Get-PnPContext $targetContentType = Get-PnPContentType -Identity "MyDocSetContentTypeName" $targetContentType.NewFormUrl = "_layouts/15/NewDocSet.aspx" $targetContentType.Update(1) $clientContext.ExecuteQuery()

@joaquinajenjo Thank you so much for posting this workaround/fix! You saved me many hours of troubleshooting.

diver7 avatar May 08 '23 16:05 diver7

I confirm the bug, however from what I understand, it does not have anything to do with module 1.11.0 vs 1.12.0, but rather with the schema that is specified in the template.

When extracting a site template using 1.11.0, the template will use schema 2021/03 while extracting a site template using 1.12.0 will generate a template that uses 2022/09, and the problem occurs using the latter.

This means you CAN use module 1.12.0 or later, but you have to downgrade the template's schema to 2021/03 to make it work.

spplante avatar Sep 05 '23 15:09 spplante

Still having this issue. How come this has not been fixed after all this time? Unable to clone a site with document sets without expensive third party tools...Frustrating

MelanieO365 avatar Oct 03 '25 14:10 MelanieO365