Skip to main content

Posts

Featured

Convert Sitecore Form Email Body to valid JSON

As part of migrating Sitecore 10 forms to Sitecore XM Cloud, when you use the existing send email parameters in Sitecore Forms, on clicking the submit button, you might encounter this parse error in browser console like "Bad control character in string literal in JSON at position 21845 (line 1 column 21846)" - since there are special characters like ' and " in the html body.  Such html characters need to be parsed/escaped and sent as part of the body in the email parameter because the desired input is in json format. So, this script does that parsing job. Just copy the contents of the unparsed body (without the opening and closing quotes) into a txt file and then execute the PS script - copied to the same location as the txt file, to get the output that you can copy over to the submit button "body"  parameter. Copy just the body value within the quotes from the generated output.

Latest Posts

My Sitecore community contribution statistics for 2025

Scaffolded Visual Studio Project for SC2025-004 hotfix

REST API that will auto publish the Sitecore item and then push the item to the initial workflow state

Azure Service Bus Consumer Without Changing Messaging Connection - Sitecore 9.3

Sitecore 9.3 on Windows 11 Pro and SQL Server 2022 with encrypted connection

PowerShell Script - establish SQL Server connection encryption for Sitecore 10.4.1 successful connectivity

Console app that shards Local Xdb and migrates contacts/interactions to new shard DB