pnp / modernization

All modernization tooling and guidance
http://aka.ms/sppnp-modernize
MIT License
156 stars 86 forks source link

Transforming sites to modern experience - web parts mapping doesn't work #384

Closed DJ-RIT closed 4 years ago

DJ-RIT commented 4 years ago

We‘re currently working on a script that transforms SharePoint 2010 on-prem Wiki and Publishing pages to modern pages on SPO using the command ConvertTo-PnPClientSidePage. So far, we were successful with simple pages that contain text and images, however the web part mappings do not work (e.g. XSLT list view web part, document library web part,…).

We followed the guide from Bert Jansen, but so far we were not able to get the web part mapping to work and we really need this to migrate pages without manual touch up.

Attached you will find a complete example including screenshots and scripts. Any input/directions on how to tackle this issue is highly appreciated!

current script produces the following output is using the following web parts PowerShell Script + pagelayoutmapping + webpartmapping.pdf PowerShell.zip Source Publishing pages using a custom page layout

jansenbe commented 4 years ago

I've been testing this and found that for so called v3 web parts (like the XsltListViewWebPart) that not all data was retrieved, hence the transformation process did not process this. After fixing this (will be part of the January release) by retrieving and parsing the page content to grab things like zoneId and controlId the transformation process has all the info it requires.

What comes next is important to understand: page transformation will not copy the lists, it will only handle pages. So if you for example have an XSLTListviewWebPart on a page pointing to "customlist1" and on the target site collection "customlist1" does not exist than the web part will not be put on the target page. It's recommended that you use migration tools to first copy the lists you still need from the source environment to the target environment.

Important: "Shared Documents" will automatically be replaced by "Documents" and "Calendar" will be automatically replaced by "Events" to better map to the default names in modern SPO sites.

If the list does exist on the target site, then it still might be the case that some web parts are not put on the target page as they do not have have modern equivalent. By looking at the default mapping you can see which XSLTListView web parts are mapped:

          <Mapping Name="List" Default="true">
            <ClientSideWebPart Type="List" Order="20" JsonControlData="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.0&quot;,&quot;properties&quot;&#58;&#123;&quot;isDocumentLibrary&quot;&#58;false,&quot;selectedListId&quot;&#58;&quot;{ListId}&quot;,&quot;listTitle&quot;&#58;&quot;{Title}&quot;,&quot;selectedListUrl&quot;&#58;&quot;{ListServerRelativeUrl}&quot;,&quot;webRelativeListUrl&quot;&#58;&quot;{ListWebRelativeUrl}&quot;,&quot;webpartHeightKey&quot;&#58;4,&quot;selectedViewId&quot;&#58;&quot;{ListViewId}&quot;,&quot;selectedFolderPath&quot;&#58;&quot;&quot;,&quot;hideCommandBar&quot;&#58;{HideToolBar}&#125;&#125;" />
          </Mapping>
          <Mapping Name="Library" Default="false">
            <ClientSideWebPart Type="List" Order="10" JsonControlData="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.0&quot;,&quot;properties&quot;&#58;&#123;&quot;isDocumentLibrary&quot;&#58;true,&quot;selectedListId&quot;&#58;&quot;{ListId}&quot;,&quot;listTitle&quot;&#58;&quot;{Title}&quot;,&quot;selectedListUrl&quot;&#58;&quot;{ListServerRelativeUrl}&quot;,&quot;webRelativeListUrl&quot;&#58;&quot;{ListWebRelativeUrl}&quot;,&quot;webpartHeightKey&quot;&#58;4,&quot;selectedViewId&quot;&#58;&quot;{ListViewId}&quot;,&quot;selectedFolderPath&quot;&#58;&quot;&quot;,&quot;hideCommandBar&quot;&#58;{HideToolBar}&#125;&#125;" />
          </Mapping>
          <Mapping Name="Calendar" Default="false">
            <ClientSideWebPart Type="Events" Order="10" JsonControlData="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&quot;title&quot;&#58;&quot;&quot;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&quot;baseUrl&quot;&#58;&quot;{EncodedSiteCollectionUrl}&quot;&#125;,&quot;componentDependencies&quot;&#58;&#123;&quot;layoutComponentId&quot;&#58;&quot;8ac0c53c-e8d0-4e3e-87d0-7449eb0d4027&quot;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.0&quot;,&quot;properties&quot;&#58;&#123;&quot;selectedListId&quot;&#58;&quot;{ListId}&quot;,&quot;selectedCategory&quot;&#58;&quot;&quot;,&quot;dateRangeOption&quot;&#58;0,&quot;startDate&quot;&#58;&quot;&quot;,&quot;endDate&quot;&#58;&quot;&quot;,&quot;isOnSeeAllPage&quot;&#58;false,&quot;layoutId&quot;&#58;&quot;FilmStrip&quot;,&quot;dataProviderId&quot;&#58;&quot;Event&quot;,&quot;webId&quot;&#58;&quot;{WebId}&quot;,&quot;siteId&quot;&#58;&quot;{SiteId}&quot;&#125;&#125;"/>
          </Mapping>
          <Mapping Name="Issue" Default="false">
            <ClientSideWebPart Type="List" Order="10" JsonControlData="&#123;&quot;serverProcessedContent&quot;&#58;&#123;&quot;htmlStrings&quot;&#58;&#123;&#125;,&quot;searchablePlainTexts&quot;&#58;&#123;&#125;,&quot;imageSources&quot;&#58;&#123;&#125;,&quot;links&quot;&#58;&#123;&#125;&#125;,&quot;dataVersion&quot;&#58;&quot;1.0&quot;,&quot;properties&quot;&#58;&#123;&quot;isDocumentLibrary&quot;&#58;false,&quot;selectedListId&quot;&#58;&quot;{ListId}&quot;,&quot;listTitle&quot;&#58;&quot;{Title}&quot;,&quot;selectedListUrl&quot;&#58;&quot;{ListServerRelativeUrl}&quot;,&quot;webRelativeListUrl&quot;&#58;&quot;{ListWebRelativeUrl}&quot;,&quot;webpartHeightKey&quot;&#58;4,&quot;selectedViewId&quot;&#58;&quot;{ListViewId}&quot;,&quot;selectedFolderPath&quot;&#58;&quot;&quot;,&quot;hideCommandBar&quot;&#58;{HideToolBar}&#125;&#125;" />
          </Mapping>
          <Mapping Name="TaskList" Default="false">
            <ClientSideText Text="There's no OOB replacement for web part {Title}. Custom web parts might be helpfull here" Order="10"/>
          </Mapping>
          <Mapping Name="DiscussionBoard" Default="false">
            <ClientSideText Text="There's no OOB replacement for web part {Title}. Custom web parts might be helpfull here" Order="10"/>
          </Mapping>
          <Mapping Name="Survey" Default="false">
            <ClientSideText Text="There's no OOB replacement for web part {Title}. Custom web parts might be helpfull here" Order="10"/>
          </Mapping>
          <Mapping Name="Undefined" Default="false">
            <ClientSideText Text="No mapping possible for web part {Title}" Order="10"/>
          </Mapping>

So TaskList, DiscussionBoard and Survey web parts are not replaced as we've no modern version for them. You could plug in a custom developed alternative if you really depend on these web parts.

I would recommend trying the transformation again with the January release once available and start with the OOB webpartmapping file (simply don't specifying a webpartmapping argument will make the transformation use the default mapping).

jansenbe commented 4 years ago

Hi @DJ-RIT ,

Can you verify if things work with the January release?

jansenbe commented 4 years ago

Hi @DJ-RIT ,

Hope things are now working for you, if not then please let me know

DJ-RIT commented 4 years ago

Hi @jansenbe ,

apologies for not coming back earlier. We have just tested today on our site with the latest release but it still does not seem to work. We still get the same outcome as before - no web parts migrated but pictures.

I am attaching a migration test script for review - could you please support us if you have time and retrace it where we might have overlooked something?

migration test newscript COFIPL.zip

Let me know if you have any questions. Much appreciated!

pkbullock commented 4 years ago

Hi @DJ-RIT

With the ConvertClientSitePage.ps1 script could you add -LogVerbose ` to line 150 and re-run the transform, this gives use more diagnostic info about the problem?

Please post the MD output back here.

Thanks Paul

pkbullock commented 4 years ago

Hi @DJ-RIT ,

I appears that the web parts are not being recognized correctly, a set of properties are used to detect the type of web parts, these are not recognised.

Paul

DJ-RIT commented 4 years ago

Here we go, will this help please? MicrosoftTeams-image (2)

pkbullock commented 4 years ago

Ok thanks, it maybe early next week before i can look at this, will try sooner if possible.

To note: I found the types are coming back as "NonExportable_Unidentified" at https://github.com/SharePoint/sp-dev-modernization/blob/fe6e932598d9de0975291a7f153b962ad8869e01/Tools/SharePoint.Modernization/SharePointPnP.Modernization.Framework/Pages/BasePage.cs#L706

It maybe the web parts contain properties that are not being properly matched to their type for 2010 transformations. Will get back to you.

Paul

Paul

jansenbe commented 4 years ago

Can you cross check you're using the latest PS version? I've seen some folks having issues with updating PnP PowerShell. Can you run below script to check the loaded version:

$module = get-module -Name SharePointPnP.PowerShell.Online.Commands
$module | fl
jansenbe commented 4 years ago

Nevermind the above comment, looking in the log you shared I see Engine version | 1.0.2001.0, so you're using the latest version. We'll need to look further:

Can you add -LogVerbose to the ConvertTo-PnPClientSidePage cmdlet in your script and share the verbose log output?

DJ-RIT commented 4 years ago

The -LogVerbose is in the attached zip file from yesterday.

jansenbe commented 4 years ago

Thanks for confirming that

jansenbe commented 4 years ago

Are you using anything specific for authenticating to SharePoint? Trying to rule out that the ASMX service calls fail. If you could do a Fiddler trace while transforming the page that fails I can see if the ASMX calls fail. Probably best to mail that directly to me (bjansen@microsoft.com) instead of adding it here

I've a SP2010 lab with a version that's older then yours in which I can transform xsltlistview web parts, so in theory this can work...so let's keep digging until we have it working for you as well.

pkbullock commented 4 years ago

I have managed to repo this and working on some code tweaks, PR coming soon, once i do bit more testing.

jansenbe commented 4 years ago

What's the root cause @pkbullock ? I can cross verify this in the fiddler trace + want to also repro this in my lab

jansenbe commented 4 years ago

We have slightly different implementations for web parts living in a web part zone vs inline web parts...might be related to this...

jansenbe commented 4 years ago

I can confirm that web part living in a web part zone are not correctly transformed. When the same web part lives in a html content field things work as expected. Most likely due to the 2 different implementations we have for web part property retrieval

pkbullock commented 4 years ago

Hi @jansenbe sorry for the delay, yes when the page uses web part zones in pages for example the BlankWebPartPage page layout, the XML properties retrieved for the web part are not exactly the same for other versions of SharePoint, so when we match properties to determine the type, it is not found.

I have made corrections to the code for this scenario, to restore conversion for supported web parts.

@DJ-RIT some web parts will not convert because they are not supported, like @jansenbe mentioned in this issue.

Will submit PR shortly and start testing.

jansenbe commented 4 years ago

@DJ-RIT : both @pkbullock and me could repro the issue and the change done by @pkbullock does fix the issue. This change has been committed and will be part of the February release which we'll release on either Feb 14 or Feb 17.

Fixing this one took longer than usual, but hope that as of the February release you'll be unblocked. Thanks for your testing and for the feedback you've provided.

jansenbe commented 4 years ago

@DJ-RIT : the February release is coming out today (or next week Monday latest)...I'm closing this issue, if you still have problems with that release then please create a new issue describing the new problem. Think it's easier that way.