This post is inspired by Libby Posadas who asked on Success Community how to export all notes from both Enhanced Notes and Classic Notes & Attachments related lists.

libby-posadas-question-export-notes

Regardless the reason, whether to migrate to another object or to simply backup the data, at first blush this was not a trivial task using typical data export means like Data Loader or Reports.

ContentNotes Sharing Model

The new Note-taking tool uses the ContentNote object which is based on the ContentVersion (Salesforce Files) object. The Notes are related to other records like Accounts, Contacts, etc. via ContentDocumentLink junction object.

contentnote-erd-summer17
ContentNote ERD as of Summer ’17

Unlike the old Note-taking tool which uses the Note object, the sharing model and record access to ContentNote and ContentVersion is very particular.

As an admin with “Modify All Data” you can export any classic Note record simply using Data Loader. However, with ContentNote and ContentVersion you can only export the records that are explicitly shared with you or that you own.

This means that even as an admin that using Data Loader is far more difficult to export all the ContentNotes and ContentVersions in your org. Lame-sauce.

ContentDocumentLink Workaround

There is a workaround and that is to query on ContentDocumentLink record and through parent relationship SOQL syntax retrieve information about the ContentVersion. But this workaround is a bit beastly and at one point in my conversation with Libby I tried to explain it…

doug-ayers-answer-export-notes.png

Sorry Libby! I know, I know… I’m not even speaking English in that answer let alone describing any sustainable process. But I was determined, there had to be an easier way to export the data. And then it hit me.

show-me-the-data.jpg

Data Export

As I’ve previously described in 9 Easy Ways to Export Data as .CSV, Salesforce has a Data Export feature to retrieve all data in your org, regardless your sharing settings. Now we’re talking! We can use the Data Export feature to download all our org’s ContentNotes and Notes without any SOQL Wizardry.

Instructions

  1. In Setup, navigate to Data Management | Data Export
    data-export-1.png
  2. Click on either Export Now or Schedule Export button, whichever is available
    data-export-2.png
  3. Choose file encoding (I recommend Unicode UTF-8)
  4. Check the box to include Salesforce Files and Document Versions
  5. Uncheck the box to replace carriage returns (i.e. new lines) with spaces
    data-export-3
  6. Uncheck Include all data (unless you want to export all data)
  7. Check ContentVersion (this includes Salesforce Files and Enhanced Notes)
  8. Check Note (if you want Classic Notes from “Notes & Attachments” related lists)
    data-export-4
  9. Click Save button
  10. Wait for email titled “Your Organization Data Export has completed” which includes link to your generated export (this may take several hours or a few days depending on volume of data)
  11. Click the link in the email
    data-export-5
  12. Download the zip file(s) that were generated
    data-export-6.png
  13. The zip file(s) contain .csv files for the objects exported.
    data-export-7
  14. You’ll also notice a ContentVersion folder which contains even more files, one per ContentVersion record exported.
    data-export-8
  15. The name of these files are the ContentVersion.ID which correlates to the “Id” column in “ContentVersion.csv” file. Remember, ContentVersion object is common object that includes both Salesforce Files and Enhanced Notes. You will need to filter the “ContentVersion.csv” file by column “FileType” to “SNOTE” records only.
    data-export-9
  16. For each “Id” in “ContentVersion.csv” file whose “FileType” column is “SNOTE” then in the folder “ContentVersion” exists a file with same name as the “Id” column value. The data inside that file is the actual note content with any plain text or rich-text formatting.

 

More Resources

If you’re playing with Notes, you might also be interested in my project to Convert Classic Notes to Enhanced Notes to take advantage of the new Note-taking tool.