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. These need to be parsed 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.

Comments
Post a Comment