Loading

Import notes to the ContentNote object with Data Loader

Дата публикации: Apr 3, 2026
Описание

With API version 32.0 and later, API support was added for the new 'ContentNote' object, which contains records created using the enhanced/rich-text 'Note' feature. The rich text 'Note' feature was made generally available in the Salesforce user interface as outlined in the Summer '15 Release Notes.


Rich-text Notes can be created in the Salesforce user interface. However, customers may also wish to import legacy Notes stored on a local file system into 'ContentNote' in their Salesforce organization. 


Please use the process below to use the Data Loader to accomplish this kind of import.


Note: In order to import into 'ContentNote,' you must have both Chatter and the new rich text 'Notes' feature enabled in your Salesforce organization. For instructions for how to enable and set up the new 'Notes' feature in your organization, please review Considerations for usage of note-taking tool 'Notes' and 'Files' functionality.

 
Решение

Step 1. Prepare your CSV file


You will need to prepare a CSV file with two columns mapping the values for each row you wish to insert:
 

  • Title - The title of the note. Required.
  • Content - The path on your local system to the .txt or .html file that contains the body of the note.  This can be found in the "Properties" of the file.
  • OwnerId - The User Id of the Note owner. If not included in your file, the owner defaults to the User performing the data load.

Optional Fields: Details on what calls and values are supported for each of the following fields, and the minimum Data Loader (API) version required to access each field are documented in the SOAP API Developer Guide ContentNote.
 
  • SharingPrivacy - Controls sharing privacy for a file.
  • CreatedById - The User ID for the User that created the record. Requires Enable 'Create Audit Fields' and can only be set or specified on record insert.
  • CreatedDate - The Date/Time of Note creation. See Data Types Supported by Data Loader for the correct format. This requires 'Enable Create Audit Fields' and can only be set or specified on record insert.
  • LastModifiedById - The User ID of the User who last modified the note. This requires 'Enable Create Audit Fields' and can only be set or specified on record insert.
  • LastModifiedDate - The Date/Time when the Note was last modified. This requires 'Enable Create Audit Fields' and can only be set or specified on record insert.
 
 
Sample Table:
 
 Title
Content
 Test Note 1
C:\notes\test_note_01.txt
 Test Note 2
C:\notes\test_note_02.html
 Test Note 3
C:\test_note3.txt

Note: For MAC's, the syntax is slightly different. For example: /Applications/Data Loader.app/test_note_01.txt
 

Sample CSV:
Title,Content
Test Note 1,C:\notes\test_note_01.txt
Test Note 2,C:\notes\test_note_02.html
Test Note 3,C:\test_note3.txt
 
Note: Because 'ContentNote' is based on Salesforce CRM Content functionality, the 'Content' column must contain a path to a local file. The body of the Note may NOT be contained within the CSV file.
 

Note: How to mass copy and paste file paths in to Excel .CSV File:

Windows:

  1. Navigate to file location and highlight all files you wish to import as notes
  2. While highlighted, hold down shift + right click
  3. Choose: Copy as Path (You can also find Copy Path in the expanded Home tab)
  4. Ctrl + V to paste the copied items in to Excel

MAC:

  1. Navigate to file location and highlight all files you wish to import as notes
  2. While in the right-click menu, hold down the OPTION key to reveal the “Copy (item name) as Pathname” option. or Cmd-Opt-C
  3. Paste file paths into .csv file.

 

Step 2. Prepare the 'Notes' body files on your local hard drive

 
Each Note that you wish to insert should have a corresponding .txt or .html file on your local hard drive that contains the body content of the Note itself. These files are the ones that are mapped in the CSV file created at step 1.
 
Certain special HTML characters are not supported when importing .txt and .html files to the 'Content' field of the 'ContentNote' object. To successfully import files, these special characters will need to be converted to a supported HTML character code equivalent prior to import.
 
Below are examples of unsupported characters and their suggested HTML character code replacement.
Find Special Character
Replace with...
&
&
<
&lt;
>
&gt;
"
&quot;
'
&#39;
 
 

Step 3. Insert the 'Note' with the Data Loader

 
If you prepared your CSV file and import files as noted above, you should now be ready to import your legacy 'Notes.'
 
  1. Install and Launch the Data Loader. For more, please review Considerations for Installing Data Loader.
  2. Click on Insert.
  3. Enter your login credentials.
  4. Click on Next.
  5. Check the box next to Show all Salesforce objects.
  6. Select Note (ContentNote) from the list of available objects.
  7. Click Browse... and select the CSV file you created at step 1.
  8. Click on Next.
  9. When the 'Data Selection' initialization dialog appears, confirm the number of records is correct and click on OK.
  10. Click on Create or Edit a Map on the next screen.
  11. Click on Auto-Match Fields to Columns or manually match the 'Title' and 'Content' fields to the corresponding columns of the CSV file.  For more information, see Define Data Loader Field Mappings.
  12. Click on OK to proceed.
  13. Confirm that the mapping is correct and click on Next.
  14. Click on Browse... and specify the location for the success and error files.
  15. Click on Finish.
  16. Review the warning and if you're ready to proceed, click on Yes.
     
 

Step 4. Relate the inserted 'Note' to a Parent Record with Data Loader

 
Once the Note is inserted we need to relate it to the parent record. Since the Note is stored in 'Content,' we need to insert a record to the 'Content Document Link' table in order to do this.
 
  1. Create a new CSV file with the following columns: ContentDocumentId, LinkedEntityId, ShareType, and Visibility.
  2. Locate the success log from the 'Note' import (Step 3 above) and populate the ContentDocumentId column in the new file with ID value from the success files for the 'Notes' that you want to relate to records.
  3. Populate the LinkedEntityId column with the ID of the record to which you want to relate the 'Note.'
  4. Set the ShareType and Visibility fields as desired. Repeat as needed for further records, then save your file.Note: You can only specify the values 'I' or 'V' for the standard objects since type 'C' is not supported. There is an example insert file attached to this article. To learn more about the valid values for these fields and their function, please review the ContentDocumentLink section of our SOAP API Developer Guide.
  5. Launch the Data Loader.
  6. Click on Insert.
  7. Enter your login credentials.
  8. Click on Next.
  9. Select the box next to Show all Salesforce objects.
  10. Select Content Document Link(ContentDocumentLink) from the list of available objects.
  11. Click on Browse... and select the CSV file you created in the earlier steps.
  12. Click on Next.
  13. When the 'Data Selection' initialization dialog appears, confirm the number of records is correct and click on OK.
  14. Click on Create or Edit a Map on the next screen.
  15. Click on Auto-Match Fields to Columns or manually match the fields to the corresponding columns of the CSV file.
  16. Click on OK to proceed.
  17. Confirm the mapping is correct and click on Next.
  18. Click on Browse... and specify the location for the success and error files.
  19. Click on Finish.
  20. Review the warning and if you're ready to proceed, click on Yes. At this point if you view the 'Notes' related list under the Parent record the 'Note' should now be visible.
 

Tips for troubleshooting ContentNote insert errors


The ContentNote object does not accept or support an Upsert call and fails with:

Error while calling web service operation: upsert, error was: UnexpectedErrorFault ApiFault exceptionCode='UNKNOWN_EXCEPTION' with an accompanying ErrorId that may end in '165958568' for example.

ContentNote currently provides a generic error like 'Note could not be saved.' whenever an issue is encountered while parsing the 'Note' file itself. This is often an indication of an issue with the contents of the text body (Content) file, such as special character(s) that have not been properly escaped.

The error 'Note can't be saved: INVALID_CONTENT_TYPE' is also known to occur when inserting more than 2500 ContentNote records in a sandbox environment when the 'Max number of Content Versions published per day' limit has been exceeded.

Sandbox organizations have a lower default value of 2500 in comparison to production organizations which typically have a default limit of 200000. If you have verified the content of your inserts for a .txt or .html files and you're receiving this error in sandbox, please contact Salesforce Support to request increasing the above limit.
To resolve the error, you'll need to pinpoint the affected file or files and replace the special characters with their HTML character code equivalent as described in step 2. 
 
If Data Loader reports errors on all the files in your insert, but you're able to confirm based on inspection that at least some of the files have no special characters, then follow these instructions to pinpoint the affected files:
 
  1. Set your data loader batch size to 1. For more, please review Configure Data Loader.
  2. Reattempt the import by following Step 3 above. You may see some files successfully imported.
  3. If you receive errors this time, review the error file from the import to see which rows in the CSV file produced an error.
  4. If the error file gives the 'Note could not be saved' error for any rows, review the .txt or .html file associated with that row and replace the special characters in that file with their HTML character code equivalent as described in step 2.
  5. If there are any other kinds of error messages, review and resolve those messages as well.
'If you require assistance with determining how to resolve any other errors that can't be answered by searching the Salesforce Help documents, please log a case with Salesforce Support.'
 
Now you should be able to attempt the import again, using the Error file for the previous import as your CSV import file, by following Step 3 above. For additional details, please review Error saving notes that contain HTML tags or unescaped characters'.
 
When end users insert records into the 'ContentNote' object, child 'ContentVersion' records are automatically created. to learn more, please review the ContentNote Objects section of our SOAP API Developer Guide.
 
If end users set audit fields, such as CreatedById, CreatedDate, and/or LastModifiedDate, when inserting 'ContentNotes,' the system is supposed to automatically create a corresponding 'ContentVersion' record with the correct audit field data. However, in Lightning Experience, 'Last Modified Date' in 'ContentVersion' shows 'Created Date' rather than the 'Last Modified Date.' R&D plans to change this behavior in Lightning Experience with a future release, to properly display 'Last Modified Date' instead of 'Created Date.'

The 'Documents in a User's private library must always be owned by that User,' error may occur when setting the 'OwnerId' to a User other than the one performing the 'ContentNote' insert. To resolve this, be sure you're connecting to Salesforce with the latest version of Data Loader.




Номер статьи базы знаний

000387816

 
Загрузка
Salesforce Help | Article