pnp / PnP-PowerShell

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

Apply-PnPProvisioningTemplate error when provisioning content type #2337

Open sheedydan opened 4 years ago

sheedydan commented 4 years ago

Reporting an Issue or Missing Feature

Issue observed when deploying a content type from a PnP provisioning template.

Expected behavior

Successful provisioning of the content type.

Actual behavior

When applying a PnP template containing a content type definition, the cmdlet returns the exception message:

Apply-PnPProvisioningTemplate : The 'value' argument cannot be null.
Parameter name: value
At line:1 char:1
+ Apply-PnPProvisioningTemplate -Path .\temp-dms-out.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], ArgumentNullException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate

This will error will only occur on the first instance of attempting to provision the content type. Subsequent provisioning attempts will provision successfully with out exception.

Steps to reproduce behavior

XML template used to reproduce:

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema">
  <pnp:Templates ID="CONTAINER-TEMPLATE-8963F5E4A99C476B877ED1F53C374431">
    <pnp:ProvisioningTemplate ID="TEMPLATE-8963F5E4A99C476B877ED1F53C374431" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
      <pnp:SiteFields>
        <Field Type="Boolean" DisplayName="Sensitive Access Document" EnforceUniqueValues="FALSE" Indexed="FALSE" Group="DMS Solution" ID="{fcbb4801-fc8b-43f3-8a6e-7d6d956c98e5}" SourceID="{87ab23fd-95a5-4c0e-accb-cf95ed336da2}" StaticName="Sensitive_x0020_Access_x0020_Document" Name="Sensitive_x0020_Access_x0020_Document">
          <Default>1</Default>
        </Field>
      </pnp:SiteFields>
      <pnp:ContentTypes>
        <pnp:ContentType ID="0x01010004A139153DBCBD4A92567443CE5AE346" Name="Sensitive Access Document" Description="" Group="DMS Solution" NewFormUrl="" EditFormUrl="" DisplayFormUrl="">
          <pnp:FieldRefs>
              <pnp:FieldRef ID="fcbb4801-fc8b-43f3-8a6e-7d6d956c98e5" Name="Sensitive_x0020_Access_x0020_Document" UpdateChildren="false" />
          </pnp:FieldRefs>
        </pnp:ContentType>
      </pnp:ContentTypes>     
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>
Apply-PnPProvisioningTemplate -Path .\temp-dms-out.xml 

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

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

3.14.1910.1

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

sheedydan commented 4 years ago

Output from PnPTraceLog:

powershell.exe Information: 0 : 2019-10-29 16:50:25.3487    [Extensibility Providers]   [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3487    [Extensibility Providers]   [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3487    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3487    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3597    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3597    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.3597    [Fields]    [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:25.4847    [Fields]    [15]    [Debug] Updating field {fcbb4801-fc8b-43f3-8a6e-7d6d956c98e5} in site   124ms   acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0697    [Fields]    [15]    [Debug] Code execution scope ended  709ms   acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0787    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0787    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0877    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0877    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:26.0887    [Content Types] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:27.3087    [Content Types] [15]    [Debug] Recreating existing Content Type: 0x01010004A139153DBCBD4A92567443CE5AE346 - Sensitive Access Document  1220ms  acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:27.4398    [OfficeDevPnP.Core] [0] [Information]   Creating content type 'Sensitive Access Document' (0x01010004A139153DBCBD4A92567443CE5AE346).   0ms 
powershell.exe Information: 0 : 2019-10-29 16:50:28.6498    [OfficeDevPnP.Core] [0] [Information]   Adding field (fcbb4801-fc8b-43f3-8a6e-7d6d956c98e5) to content type (0x01010004A139153DBCBD4A92567443CE5AE346). 0ms 
powershell.exe Information: 0 : 2019-10-29 16:50:29.1137    [Content Types] [15]    [Debug] Code execution scope ended  3024ms  acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:29.1137    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope started    0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:29.1137    [ProvisioningTemplate WebHook Call] [15]    [Debug] Code execution scope ended  0ms acb2331f-d763-459b-8de4-2d7ac1c1509c
powershell.exe Information: 0 : 2019-10-29 16:50:29.1137    [Provisioning]  [15]    [Debug] Code execution scope ended  4057ms  acb2331f-d763-459b-8de4-2d7ac1c1509c
tarjeieo commented 4 years ago

Same issue here, works subsequent time for each content type. Also on 3.14.1910.1 of PnP-PowerShell Online-version.

Billbrockbank commented 4 years ago

I found this error, then I have more that 1 content type in the template. Each time I ran the provisioning a content type is created okay, but it errors after creating the content type. But if I just create the content types first with "Add-PnPContentType" the provisioning does not error.

ervingayle commented 4 years ago

From what I have seen based on the trace log is that it now appears that lookup columns are being skipped. In both content types that were created it has only restored the non lookup columns. My site or list structure hasn't changed and I have generated templates and restored them recently without error. I now get the same error while running the most recent build. Only change is a change for how I generated the template now using, -ContentTypeGroup and -Handlers switches.

ervingayle commented 4 years ago

It seems that this behavior does not occur with version: SharePointPnPPowerShellOnline 3.13.1909.0. I downgraded using uninstall-module SharePointPnPPowerShellOnline -AllVersions -Confirm and generated a new template and applied it to a new communications site. The order of the restore also seems different. At some point it does Lists, Site Columns for List, Fields and Content Types in that order whereas I believe with the 1901 build it does Fields, Content Types which would explain my theory of why the lookup columns fail now. Hopefully this helps someone

Billbrockbank commented 4 years ago

After updating to SharePointPnPPowerShellOnline 3.15.1911.0 version the content type issues was fixed, but I did have a new issues, was not able to find a cause, I did a work around, I have a provisioning template the site columns, content types and lists, that errored. The work around was to use 3 separate templates 1 for the site columns, 1 for the content types and 1 for the lists. Note: the issues was in Azure Automation run book.