Pnp-powershell: Apply-PnPProvisioningTemplate with pnp:file for a publishing page with force checkout enabled

Created on 28 Oct 2019  路  6Comments  路  Source: pnp/PnP-PowerShell

Reporting an Issue or Missing Feature

pnp:file for a publishing page with force checkout enabled in pages library results in error: The file is not checked out. You have to checkout the file before making changes.
This also happens, when the file got checked out before applying the template.

Expected behavior

When a file is checked out before applying the template, the file should get updated

Actual behavior

when applying a template, an error gets thrown which says, that I have to checkout the file before I can edit it, although the file got checked out before.

Steps to reproduce behavior

  1. Add a publishing page in pages library
  2. Version Settings in Pages Library must require Checkout before editing option
  3. Export the template via 'Get-PnPProvisioningTemplate -Out test.xml -PersistPublishingFiles -PersistBrandingFiles -PersistComposedLookFiles'
  4. Apply the template via: #Apply-PnPProvisioningTemplate -Path .\test.xml

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

  • [ ] PnP PowerShell for SharePoint 2013
  • [x ] PnP PowerShell for SharePoint 2016
  • [ ] PnP PowerShell for SharePoint Online

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

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)
3.14.1910.1

How did you install the PnP-PowerShell Cmdlets?

  • [x ] MSI Installed downloaded from GitHub
  • [ ] Installed through the PowerShell Gallery with Install-Module
  • [ ] Other means
Needs

Most helpful comment

Just to report the same issue using the PnP PowerShell for SharePoint Online with templates for classic sites types.

It works until the version 3.13.1909.0. _Since version 3.14.1910.0 to 3.16.1912.0 is giving the same error_

Microsoft.SharePoint.Client.ServerException: The file "https://tenant.sharepoint.com/sites/classicteamsite/Pages/Home.aspx" is not checked out. You must first check out this document before making changes.
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser)
at Microsoft.SharePoint.Client.WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation)
at SharePointPnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate.ExecuteCmdlet()
at SharePointPnP.PowerShell.Commands.PnPCmdlet.ProcessRecord()

All 6 comments

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

I can conform I have the same issue. The same provisioning template that I used for the SharePoint 2013 with version 3.4.1812.2 did not have this issue.

Edit: forcing checkout before applying the template does not work. After some further investigation I noticed that changes are applied correctly. So, applying template does work but unfortunately it errors causing the rest of my provisioning to halt. It seems it is the and its contents that is causing problems. If I comment that out and include only the -bit, everything goes fine.

The issue seems to be introduced in https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/ObjectFiles.cs in changeset https://github.com/SharePoint/PnP-Sites-Core/commit/45081b244d7c0c72665fec8e5f53cf8649a0eca3#diff-8517941d31ab58d99a9abbec2b3b42f7 . Here, modifying the properties of the file was moved after the section where the file is checked in. Thus causing the page to have a checkedin-status when the properties are modified, causing the error.

I solved the issue for now by reverting to the release of april 2019. This is the release before the change commited. @erwinvanhunen I am tagging you, since I have no knowledge at all of actually contributing to PnP. If more information is needed, I am happy to help.

Thank you very much:-)

I hope that the change will be merged soon so we can make use of this feature.

Just to report the same issue using the PnP PowerShell for SharePoint Online with templates for classic sites types.

It works until the version 3.13.1909.0. _Since version 3.14.1910.0 to 3.16.1912.0 is giving the same error_

Microsoft.SharePoint.Client.ServerException: The file "https://tenant.sharepoint.com/sites/classicteamsite/Pages/Home.aspx" is not checked out. You must first check out this document before making changes.
at OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser)
at Microsoft.SharePoint.Client.WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation)
at SharePointPnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate.ExecuteCmdlet()
at SharePointPnP.PowerShell.Commands.PnPCmdlet.ProcessRecord()

with this information it should be possible to check the checkins / see the diffs between the version 3.13.1909.0 and 3.14.1910.0...

I will try to have a look when I am back from holyday.... maybe it is easy to find out what went wrong in the checkins or where the bug could come from.

Was this page helpful?
0 / 5 - 0 ratings