You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all. I'm using Visual Studio Code to convert wiki pages to modern site pages and retain the metadata, but it's failing to copy the metadata. It will successfully convert the page and include the created/modified info, but the metadata fields are blank in the pages it creates in SitePages. I ran the script before and after manually creating the columns in SitePages with the same results. I also ran this on 2 different wiki libraries in the same site collection with the same results. I ended up having to manually gather the metadata from the source wiki library and write it to the converted page in SitePages using the Set-PnPListItem command, so the source fields are accessible and the target fields are writable. I left that set command in the code below to show the workaround.
Columns in the source wiki library are as follows:
Wiki Content | Multiple lines of text |
A Text Column | Single line of text |
A Choice Column | Choice |
Date Time Column | Date and Time |
My Peeps | Person or Group |
Number Column of Goodness | Number |
Toggle Y/N | Yes/No |
Created | Date and Time |
Modified | Date and Time |
Created By | Person or Group |
Modified By | Person or Group |
Checked Out To | Person or Group
The Page Transformation logs will say the following:
The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. at Microsoft.SharePoint.Client.ListItem.GetFieldValue(String fieldName)
at PnP.Framework.Modernization.Transform.BasePageTransformator.CopyPageMetadata(PageTransformationInformation pageTransformationInformation, String pageType, File targetPage, List targetPagesLibrary)
at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)
Individual Page details
Transformation Details: /Test Wiki Page Library/Page With Video.aspx
Transforming page: /sites/SonyaTestSite/Test Wiki Page Library/Page With Video.aspx
Source SharePoint version: Online (16.0.0.23912)
A critical error occurred - transformation did not complete
Page Transformation Settings
Property
Setting
Engine version
1.13.1.0
Target Page Takes Source Page Name
False
Target Page Prefix
Migrated_
Source Page Prefix
Previous_
Copy Page Metadata
True
Set Author In Page Header
False
Replace Home Page With Default Home Page
False
Overwrite
True
Target Page Name
Target Page Folder
Target Page Folder Overrides Default Folder
False
Keep Page Specific Permissions
True
Remove Empty Sections And Columns
True
Handle Wiki Images And Videos
True
Add Table List Image As Image Web Part
True
Keep Page Creation Modification Information
True
Publish Created Page
True
Post As News
False
Disable Page Comments
False
Skip Url Rewrite
False
Skip Default Url Rewrite
False
Url Mapping File
Skip Hidden Web Parts
False
Term Mapping File
Skip Term Store Mapping
False
Skip User Mapping
False
User Mapping File
L D A P Connection String
Skip Telemetry
False
Transformation Operation Details
Date
Operation
Actions Performed
8/2/2023 2:18:15 PM
Input Validation
Validation checks complete
8/2/2023 2:18:15 PM
SharePoint Connection
Loading client context objects
8/2/2023 2:18:15 PM
Page Creation
Detect if the page is living inside a folder
8/2/2023 2:18:15 PM
Page Creation
The transform page is located in a folder
8/2/2023 2:18:15 PM
Page Creation
Using the supplied prefix
8/2/2023 2:18:15 PM
Page Creation
Just try to load the page in the fastest possible manner, we only want to see if the page exists or not
8/2/2023 2:18:16 PM
Load
Page does not exist in current web
8/2/2023 2:18:16 PM
Page Creation
Checking Page Exists
8/2/2023 2:18:16 PM
Page Creation
Modern page created
8/2/2023 2:18:16 PM
Home page handling
Check if the transformed page is the web's home page
8/2/2023 2:18:16 PM
Home page handling
Welcome page setting does exist, checking if the transform page is a home page
8/2/2023 2:18:16 PM
Home page handling
The current page is not used as the site home page
8/2/2023 2:18:16 PM
Article page handling
Transforming source page as Article page
8/2/2023 2:18:16 PM
Article page handling
Page Header Set to None. Removing the page header
8/2/2023 2:18:16 PM
Article page handling
Recognized source page as a Wiki Page. - Analyzing web parts and page layouts
8/2/2023 2:18:16 PM
Article page handling
No web parts were found on page
8/2/2023 2:18:16 PM
Article page handling
Splitting images and videos from wiki text - as modern text web part does not support embedded images and videos
8/2/2023 2:18:16 PM
Set Page Title
Setting the modern page title: Page With Video
8/2/2023 2:18:16 PM
Article page handling
Preparing content transformation
8/2/2023 2:18:16 PM
Article page handling
Transforming content
8/2/2023 2:18:16 PM
Content Transform
Transforming web parts
8/2/2023 2:18:16 PM
Web Part Mapping
Web Part:'Wiki text' of type 'SharePointPnP.Modernization.WikiTextPart' is being transformed
8/2/2023 2:18:16 PM
Web Part Mapping
Processing selector functions
8/2/2023 2:18:16 PM
Web Part Mapping
Combining mapping data
8/2/2023 2:18:16 PM
Adding Web Parts to Target Page
Added 'Client Side Text Web Part' to target page
8/2/2023 2:18:16 PM
Web Part Mapping
Web Part:'Video in wiki text' of type 'SharePointPnP.Modernization.WikiVideoPart' is being transformed
8/2/2023 2:18:16 PM
Web Part Mapping
Processing selector functions
8/2/2023 2:18:16 PM
Web Part Mapping
Combining mapping data
8/2/2023 2:18:16 PM
Adding Web Parts to Target Page
Using 'ContentEmbed' modern web part
8/2/2023 2:18:16 PM
Adding Web Parts to Target Page
Added 'Embed' Client Side Web Part to target page
8/2/2023 2:18:16 PM
Web Part Mapping
Web Part:'Wiki text' of type 'SharePointPnP.Modernization.WikiTextPart' is being transformed
8/2/2023 2:18:16 PM
Web Part Mapping
Processing selector functions
8/2/2023 2:18:16 PM
Web Part Mapping
Combining mapping data
8/2/2023 2:18:16 PM
Adding Web Parts to Target Page
Added 'Client Side Text Web Part' to target page
8/2/2023 2:18:16 PM
Content Transform
Transforming web parts complete
8/2/2023 2:18:16 PM
Article page handling
Transforming content complete
8/2/2023 2:18:17 PM
Article page handling
Saved page: Test Wiki Page Library/Migrated_Page With Video.aspx
Code is as follows:
function WriteDone()
{
WriteHost "Done." -ForegroundColor Green
}
$SourceConnection = Connect-PnPOnline -Url $SourceSite -devicelogin
$wikiPageLibraryName = "Test Wiki Page Library"
$getLibraryFolderItems = ""
$count = 0
$errors = 0
try {
Write-Host "Gathering the wiki library pages from: $($wikiPageLibraryName)"
$getLibraryFolderItems = Get-PnPListItem -List $wikiPageLibraryName -PageSize 500 #-Connection $SourceConnection
Write-Host "Files found: $($getLibraryFolderItems.Count)"
} catch {
Write-Host "Error while getting pages from the wiki library: " -ForegroundColor Red
Write-Host "$($_.Exception.Message)" -ForegroundColor Red
Write-Host " "
$errors++
Exit 1
}
foreach($page in $getLibraryFolderItems) {
Write-Host "--------------------------------------------------------------------"
try {
Write-Host "Attempting to convert: $($page.FieldValues["FileLeafRef"])" -ForegroundColor Yellow
ConvertTo-PnPPage -Identity $page.FieldValues["FileLeafRef"] -Library $wikiPageLibraryName -Overwrite -KeepPageCreationModificationInformation -CopyPageMetadata -LogType File -LogFolder $LogOutputFolder -LogVerbose #-Connection $SourceConnection
#Start-Sleep -Seconds 2
WriteDone
Write-Host "Getting the migrated page's ID..."
$theNewPage = Get-PnPFolderItem -FolderSiteRelativeUrl "SitePages/$($wikiPageLibraryName)" -ItemName "Migrated_$($page.FieldValues['FileLeafRef'])" # Get the new page in Site Pages; this doesn't include the page's ID
$getTheNewPageProperties = Get-PnPPage -Identity $theNewPage.Name # Need this to get the Id of the new page
WriteDone
<# I can manually gather and write the metadata with this commented section, so the fields are accessible and writable. But if I don't run the Set-PnPListItem commandlet, the metadata from the source wiki library doesn't write to the migrated page in SitePages.
Write-Host "Attempting to write metadata to the migrated page..."
Set-PnPListItem -List "SitePages" -Identity $getTheNewPageProperties.PageId -Values @{
"AChoiceColumn" = "$($page.FieldValues["AChoiceColumn"])";
"ATextColumn" = "$($page.FieldValues["ATextColumn"])";
"DateTimeColumn" = "$($page.FieldValues["DateTimeColumn"])";
"MyPeeps" = "$($page.FieldValues["MyPeeps"].Email)";
"NumberColumnofGoodness" = "$($page.FieldValues["NumberColumnofGoodness"])";
"ToggleY_x002f_N" = "$($page.FieldValues["ToggleY_x002f_N"])"
} -ErrorAction Continue
WriteDone
#>
#Remove "Migrated_" from the beginning of the migrated filenames
Write-Host "Removing 'Migrated_' that was auto-added to the new page's name..."
$removeMigratedTag = Rename-PnPFile -SiteRelativeUrl "SitePages/$($wikiPageLibraryName)/Migrated_$($page.FieldValues['FileLeafRef'])" -TargetFileName $page.FieldValues["FileLeafRef"] -Force
WriteDone
$count++
Write-Host "Items processed: $($count)"
$theNewPage = ""
$getTheNewPageProperties = ""
Write-Host " "
} catch {
Write-Host "Error while converting wiki page: " -ForegroundColor Red
Write-Host "$($_.Exception.Message)" -ForegroundColor Red
Write-Host " "
$errors++
Exit 0
}
}
Write-Host "--------------------------------------------" -ForegroundColor re Green
Write-Host "--------------------------------------------" -ForegroundColor Green
Write-Host "Total files processed: $($count)" -ForegroundColor Yellow
Write-Host "Errors found: $($errors)" -ForegroundColor Red
Expected behavior
Please describe what output you expect to see from the PnP PowerShell Cmdlets
I expected the metadata from pages in the source wiki library to be written to the corresponding columns in the folder the ConvertTo-PnPPage commandlet creates in SitePages.
Actual behavior
Please describe what you see instead. Please provide samples of output or screenshots.
The wiki pages are converted to modern and the created/modified info is correct on the converted pages, but the metadata is not written so the fields on the target pages are blank.
What is the version of the Cmdlet module you are running?
This discussion was converted from issue #3326 on October 11, 2024 19:18.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Reporting an Issue or Missing Feature
Hi all. I'm using Visual Studio Code to convert wiki pages to modern site pages and retain the metadata, but it's failing to copy the metadata. It will successfully convert the page and include the created/modified info, but the metadata fields are blank in the pages it creates in SitePages. I ran the script before and after manually creating the columns in SitePages with the same results. I also ran this on 2 different wiki libraries in the same site collection with the same results. I ended up having to manually gather the metadata from the source wiki library and write it to the converted page in SitePages using the Set-PnPListItem command, so the source fields are accessible and the target fields are writable. I left that set command in the code below to show the workaround.
Columns in the source wiki library are as follows:
Wiki Content | Multiple lines of text |
A Text Column | Single line of text |
A Choice Column | Choice |
Date Time Column | Date and Time |
My Peeps | Person or Group |
Number Column of Goodness | Number |
Toggle Y/N | Yes/No |
Created | Date and Time |
Modified | Date and Time |
Created By | Person or Group |
Modified By | Person or Group |
Checked Out To | Person or Group
The Page Transformation logs will say the following:
Modernization Summary Report
Critical Errors during transformation
8/2/2023 2:18:18 PM - [/Test Wiki Page Library/Page With Video.aspx](https://XXXXXX.sharepoint.com/sites/SonyaTestSite/Test Wiki Page Library/Page With Video.aspx)
The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. at Microsoft.SharePoint.Client.ListItem.GetFieldValue(String fieldName)
at PnP.Framework.Modernization.Transform.BasePageTransformator.CopyPageMetadata(PageTransformationInformation pageTransformationInformation, String pageType, File targetPage, List targetPagesLibrary)
at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)
Individual Page details
Transformation Details: /Test Wiki Page Library/Page With Video.aspx
Page Transformation Settings
Transformation Operation Details
Code is as follows:
Expected behavior
Please describe what output you expect to see from the PnP PowerShell Cmdlets
I expected the metadata from pages in the source wiki library to be written to the corresponding columns in the folder the ConvertTo-PnPPage commandlet creates in SitePages.
Actual behavior
Please describe what you see instead. Please provide samples of output or screenshots.
The wiki pages are converted to modern and the created/modified info is correct on the converted pages, but the metadata is not written so the fields on the target pages are blank.
What is the version of the Cmdlet module you are running?
get-module -Name "PnP.PowerShell" returns:
Manifest 2.2.0 PnP.PowerShell {Add-PnPAlert, Add-PnPApp, Add-PnPApplicationCustomizer, Add-PnPAvailableSiteClassification…}
Get-Module -Name "PnP.PowerShell" -ListAvailable returns:
Directory: C:\Users<my account>\OneDrive
Manifest 2.2.0 PnP.PowerShell Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Manifest 2.1.1 PnP.PowerShell Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Directory: C:\Program Files\WindowsPowerShell\Modules
Manifest 1.12.0 PnP.PowerShell Core,Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Which operating system/environment are you running PnP PowerShell on?
Windows 10 Enterprise
Visual Studio Code version: 1.79.22
Beta Was this translation helpful? Give feedback.
All reactions