pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
204 stars 141 forks source link

[BUG] Cannot migrate WebPart Page in Publishing Pages Library #113

Closed rroman81 closed 3 years ago

rroman81 commented 3 years ago

Thank you for reporting a bug. We appreciate your feedback - to help the team to understand your needs, please complete the below template to ensure we have the necessary details to assist you. Thanks!

Problem Area

[x] Page Transformation: Error during the use of page transformation from PnP PowerShell [ ] Page Transformation: Error during the use of page transformation from .Net [ ] Page Transformation: Page is not looking correct after transformation [ ] Modernization Scanner: something went wrong...

Expected or Desired Behavior

When migrating Cross-site (from SP2010 Pages Library to O365) WebPart pages that are in Publishing Pages library, my expectation is that they are migrated just like any other pages inheriting from Page content type.

Observed Behavior

Currently the page cannot be migrated as it's detected as PageType=WebPartPage, and produces an error Page is not a publishing page, please use the wiki and web part page API's. https://github.com/pnp/sp-dev-modernization/blob/8d464706f7e0125dcaceac31fa763f57240a30a0/Tools/SharePoint.Modernization/SharePointPnP.Modernization.Framework/Extensions/ListItemExtensions.cs#L26-L52

Steps to Reproduce

Import-Module -Name SharePointPnPPowerShellOnline -RequiredVersion 3.23.2007.1
$sourceConnection = Connect-PnPOnline -Url https://[tenant].company.com/pub/[sourcesitename] -ReturnConnection
$destinationConnection = Connect-PnPOnline -Url https://[tennat].sharepoint.com/sites/[destsitename] -ReturnConnection
$pagesList = Get-PnPList -Idenitty "Pages" -Connection $sourceConnection
$sourcePage = Get-PnPListItem -List $pagesList  | ?{ $_.FieldValues["FileLeafRef"] -eq "Agile.aspx" }
ConvertTo-PnPClientSidePage -Identity $sourcePage.FieldValues["ID"] -TargetWebUrl https://[tenant].sharepoint.com/sites/[sitename] -PublishingPage -PublishingTargetPageName "Agile_Modernized.aspx" -TargetConnection $destinationConnection -DontPublish -CopyPageMetadata -SkipItemLevelPermissionCopyToClientSidePage -Connection $sourceConnection -Verbose -LogVerbose -LogType Console

Console output:

VERBOSE: Using embedded webpartmapping file. Use Export-PnPClientSidePageMapping to get that file in case you want to base your version of the embedded version.
[Page Transformation Information] Engine version = 1.0.2007.0
[Page Transformation Information] Overwrite = False
[Page Transformation Information] Target Page Name = Agile_Modernized.aspx
[Page Transformation Information] Target Page Folder =
[Page Transformation Information] Target Page Folder Overrides Default Folder = False
[Page Transformation Information] Keep Page Specific Permissions = False
[Page Transformation Information] Remove Empty Sections And Columns = True
[Page Transformation Information] Handle Wiki Images And Videos = True
[Page Transformation Information] Add Table List Image As Image Web Part = True
[Page Transformation Information] Keep Page Creation Modification Information = False
[Page Transformation Information] Publish Created Page = False
[Page Transformation Information] Post As News = False
[Page Transformation Information] Disable Page Comments = False
[Page Transformation Information] Skip Url Rewrite = False
[Page Transformation Information] Skip Default Url Rewrite = False
[Page Transformation Information] Url Mapping File =
[Page Transformation Information] Term Mapping File =
[Page Transformation Information] Skip Term Store Mapping = False
[Page Transformation Information] Skip User Mapping = False
[Page Transformation Information] User Mapping File =
[Page Transformation Information] L D A P Connection String =
[Page Transformation Information] Skip Telemetry = False
Error: [Input Validation] Page is not a publishing page, please use the wiki and web part page API's Error: No error logged StackTrace: No trace logged
ConvertTo-PnPClientSidePage : Page is not a publishing page, please use the wiki and web part page API's
At line:1 char:1
+ ConvertTo-PnPClientSidePage -Identity $sourcePage.FieldValues["ID"] - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [ConvertTo-PnPClientSidePage], ArgumentException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.ClientSidePages.ConvertToClientSidePage
PS C:\Users\user\migration> Get-PnPException

CorrelationId    : e77e9c9f-100f-b000-a9d4-74249d313d33
TimeStampUtc     : 12/31/2020 7:01:50 AM
Message          : Page is not a publishing page, please use the wiki and web part page API's
Stacktrace       :    at SharePointPnP.Modernization.Framework.Publishing.PublishingPageTransformator.Transform(PublishingPageTransformationInformation publishingPageTransformationInformation)
                      at SharePointPnP.PowerShell.Commands.ClientSidePages.ConvertToClientSidePage.ExecuteCmdlet()
                      at SharePointPnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord()
ScriptLineNumber : 1

PS C:\Users\user\migration> Get-Module -Name SharePointPnPPowerShellOnline | fl

Name              : SharePointPnPPowerShellOnline
Path              : C:\Program Files\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline\3.23.2007.1\SharePointPnP.PowerShell.Online.Commands.dll
Description       : SharePoint Patterns and Practices PowerShell Cmdlets for SharePoint Online
ModuleType        : Binary
Version           : 3.23.2007.1
NestedModules     : {}
ExportedFunctions :
ExportedCmdlets   : {Add-PnPAlert, Add-PnPApp, Add-PnPApplicationCustomizer, Add-PnPClientSidePage...}
ExportedVariables :
ExportedAliases   : {Add-PnPOffice365GroupToSite, Add-PnPUnifiedGroupMember, Add-PnPUnifiedGroupOwner, Clear-PnPMicrosoft365GroupMember...}

Thank you.

jansenbe commented 3 years ago

Moving this issue to the PnP Framework repo as that's where we now host the modernization code.

jansenbe commented 3 years ago

@rroman81 : web part pages do not belong in the publishing pages library...

Looking at your script I see you specify the -PublishingPage parameter...indicating this is a publishing page. For transforming wiki/webpart pages you do not need to specify that. See https://docs.microsoft.com/en-us/sharepoint/dev/transform/modernize-userinterface-site-pages-powershell for docs.

If that does not work then please move the web part page out of the publishing pages library and into a regular library and convert from there.

jansenbe commented 3 years ago

@rroman81 : did above help? If so please close this issue

jansenbe commented 3 years ago

Closing per no feedback. Feel free to open a new issue if the problem still persists