ContentNote insert error: Note Can't Be Saved Because It Contains HTML Tags Or Unescaped Characters That Are Not Allowed In A Note
|Knowledge Article Number||000232870|
|Description||If your organization has Set Up Notes to enable the enhanced note-taking tool, user's may encounter the following error when inserting ContentNote records via the API using Data Loader.
Note can't be saved because it contains HTML tags or unescaped characters that are not allowed in a Note.
|Resolution||You must use the Data Loader when inserting ContentNote object records. Attempting to insert ContentNote records via Workbench for example will always result in this error.
It is recommended to use the most recent version of the Data Loader available but a minimum of version 32 required.
A batch size of 1 is highly recommended to ensure the best success rates when inserting ContentNote records and is ideal for identifying the exact records or rows in your file that resulted in the error.
If you are following the steps in the Importing Notes to the ContentNote object using the Apex Data Loader article you will note that you can specify the file path to either an HTML or TXT file on your local machine. Due to the constraints outlined below for the .html file type, it is recommended to use a .txt file on insert for the best result.
.html file type requirements and limitations:
- Special characters will need to be replaced in the file or you will encounter the error.
- Formatting made via HTML is not preserved on insert and escaped HTML code is inserted as plain text in the Note's body.
.txt file type requirements and limitations:
- Include line breaks in your file by inserting the <br> HTML tag otherwise, line breaks will not be present in the note's body and replaced with spaces.
- Do not escape HTML tags contained in your .txt file otherwise the tags will input as plain text.
- The following tags or elements in bold are accepted in the .txt file in order to format the note's text:
- You may use multiple tags when formatting text but they must be closed in the correct sequence otherwise you will encounter the insert error. For example;
<strong><i><u>Formatted Text</i></strong></u> results in the error where as,
<strong><i><u>Formatted Text</u></i></strong> is inserted successfully.
- Save the file as UTF-8
Note: It's not currently possible to insert Notes via the Data Loader with advanced formatting such as unordered (bullets) and ordered (numbered) lists or indentations using either a .html or .txt file.
There is no direct path or tool available to prepare data or migrate legacy notes to the enhanced note-taking tool and externally manipulating the data outside of Salesforce is required to properly prepare files for insert.
As an alternative to migrating legacy notes to enhanced notes, consider maintaining the legacy Notes & Attachments related list on page layouts so that users can continue to view and reference past notes while instructing them to add and work with new notes via the Notes related list moving forward.
Considerations for enabling the enhanced note-taking tool (Notes) and using Files