pnp / modernization

All modernization tooling and guidance

Home Page:http://aka.ms/sppnp-modernize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] : Script Editor webpart / Content Editor webpart not getting transformed as Modern Script Editor webparts during site Modernization using PnP Cmdlets.

sabrahamAmicus opened this issue · comments

Script Editor webpart / Content Editor webpart not getting transformed as Modern Script Editor webparts during site Modernization using PnP Cmdlets.

The Modern Script Editor webpart has been uploaded to App catalog.

Using -UseCommunityScriptEditor flag for ConvertTo-PnPPage

For a Page with Script Editor webpart

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">$("#placeholder").load("https://xxxxxxxxxxxx.sharepoint.com/sites/xxxxxx/SiteAssets/xxxxx.html");</script>

We are getting the following error
0x0D' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 | BytePositionInLine: 213. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan1 data, Int32 idx) at System.Text.Json.Utf8JsonReader.ConsumeString() at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, Utf8JsonReader reader, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedBytes) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at PnP.Core.Model.SharePoint.PageWebPart.set_PropertiesJson(String value) at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List1 webParts) at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)

@sabrahamAmicus
I had this issue too, basically 0x0D is a new line character. If this is only for one page, can you please try to remove all new line characters from the script? so the script will be one line only. It worked for me.

If this is for all pages, then you will need to create a PS script to clean the content and strip out new line, tab, and the return characters.

This issue will appear when we're transforming page content, script editor, and content editor webpart.

@natpdeee is correct. See also pnp/pnpframework#621. Closing this one here, if still an issue please open new issue in the PnP Framework repo.

I am also getting the exactly same issue. It is working fine if I remove the newline character from the script. But for us it is a lot of pages and will not be feasible to manually remove the newline character from each script. Is there any alternative solution to fix this issues for all of the pages.

Details:

Name Version


SharePointPnPPowerShellOnline 3.29.2101.0