I am trying to do insertion with Salesforce Ligtning ContentNotes through Data Loader.

How can I insert a ContentNote with related object? For example, I have a note 1 with Title: "Note 1" and Content: "Hi, this is content1" and want to relate this record to Lead 1 record.


I found a solution here: Importing Notes to the ContentNote object using the Apex Data Loader.

Step 4. Relating the inserted Note to a Parent Record with the Apex 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 that you want to relate the Note to.
  4. Set the ShareType and Visibility fields as desired. Documentation here describes the valid values for these fields and their function, there is also an example insert file attached to this article. Repeat as needed for further records then save your file.(Please note that you can only specify the values 'I' or 'V' for the standard objects since type 'C' is not supported)
  5. Launch the Apex Data Loader.
  6. Click "Insert".
  7. Enter your login credentials.
  8. Click "Next".
  9. Check the box next to "Show all Salesforce objects"
  10. Select "Content Document Link(ContentDocumentLink)" from the list of available objects.
  11. Click "Browse..." and select the CSV file you created in the earlier steps.
  12. Click "Next"
  13. When the Data Selection initialization dialog appears, confirm the number of records is correct and click "OK".
  14. Click "Create or Edit a Map" on the next screen.
  15. Click "Auto-Match Fields to Columns" or manually match the fields to the corresponding columns of the CSV file.
  16. Click "OK" to proceed.
  17. Confirm the mapping is correct and click "Next"
  18. Click "Browse..." and specify the location for the success and error files.
  19. Click "Finish".
  20. Review the Warning and if you're ready to proceed, click "Yes". At this point if you view the Notes related list under the Parent record the Note should now be visible.
  • Hey Anthony, link only answers tend to break over time, so best practice on this exchange is to include the relevant excerpt. I went ahead and did so here. – Adrian Larson Jun 30 '16 at 17:30
  • Thanks @AdrianLarson, I found that document also shortly after I posted it. But that is also good to know, to post the relevant content! Thanks for the good tip! – Anthony Gawon Lee Jun 30 '16 at 19:54
  • Also don't forget to accept your own answer if it resolved the issue! That way the community is not confused about whether or not it is still an open question. – Adrian Larson Jun 30 '16 at 19:57
  • Sounds great, it is saying I need to wait 2 days to accept my own answer. I will do that. Thanks for all your help @AdrianLarson! – Anthony Gawon Lee Jul 1 '16 at 2:55
  • Ha. No wonder it's easy to forget. – Adrian Larson Jul 1 '16 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.