[ ] Bug
[X] Enhancement
[ ] Page Transformation: Error during the setup/use of the Page Transformation UI solution (did you check our troubleshooting guide?)
[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...
I would like the option to preserve the created/modified dates where possible.
The modernisation doesn't do this, including using the CopyPageMetadata switch.
I have seen documentation for PnP-PowerShell that this is an option: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/add-pnpfile?view=sharepoint-ps so its possible to acheive.
Good feedback @pkbullock. I assume if you want to retain the modification/creation date you also want to retain the user who created/modified the page? To stay backward compatible I see this behavior is triggered by a custom flag.
Include who but if not resolved then fall back to System Account (think I have code somewhere to get this) - ideally not my name. Make sense for custom flag, there maybe cases where others may not need this preserved.
I'm currently testing the same thing and you can archive it creating a custom page layout file with the following mapping:
<MetaData>
...
<Field Name="Created" TargetFieldName="Created" Functions="" />
<Field Name="Modified" TargetFieldName="Modified" Functions="" />
<Field Name="Author" TargetFieldName="Author" Functions="" />
<Field Name="Editor" TargetFieldName="Editor" Functions="" />
...
</MetaData>
With this in place, you need to run the transformation and all fields will retain their value:
ConvertTo-PnPClientSidePage ... -PageLayoutMapping "C:\...\custompagelayoutmapping.xml" -CopyPageMetadata
@eduardpaul thanks for sharing this, working like a charm! This might be a good one to record as sample or put in FAQ in docs.
So bit more testing revealed that when publishing the date is updated after publish then remains in draft state.
Hi @pkbullock I think you need to update the first published date field in order to publish a modern page:
<Field Name="PublishingStartDate" TargetFieldName="FirstPublishedDate" Functions="" />
And use this if you want to promote the page to News:
<Field Name="ID" TargetFieldName="PromotedState" Functions="StaticString('2')" />
Hope it helps :)
Nice way of using the publishing layout templates @eduardpaul :-) Would be indeed a good one to document.
@eduardpaul : do you need a native "promote as news" option? I initially assumed content authors would first want to verify the pages before actually promoting them as news...the PnP Client Side Page API does support this, so it would be a fairly trivial change.
Just checked the code in the Client Side Pages API and we always set the FirstPublishedDate to now...so think it's better to keep @eduardpaul 's approach for now. Will include that in the docs, closing this issue now.