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.
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.

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…
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.
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
- In Setup, navigate to Data Management | Data Export
- Click on either Export Now or Schedule Export button, whichever is available
- Choose file encoding (I recommend Unicode UTF-8)
- Check the box to include Salesforce Files and Document Versions
- Uncheck the box to replace carriage returns (i.e. new lines) with spaces
- Uncheck Include all data (unless you want to export all data)
- Check ContentVersion (this includes Salesforce Files and Enhanced Notes)
- Check Note (if you want Classic Notes from “Notes & Attachments” related lists)
- Click Save button
- 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)
- Click the link in the email
- Download the zip file(s) that were generated
- The zip file(s) contain .csv files for the objects exported.
- You’ll also notice a ContentVersion folder which contains even more files, one per ContentVersion record exported.
- 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.
- 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.
Very simple method but the use of SOQL was very informative. I have a question and please correct me if I’m wrong but I think ContentDocumentLink is not a junction object since the direction of the relationships is reversed? It is the link between the two objects but it’s on the “Master” side of the relation.
LikeLiked by 1 person
Hi Tamar,
Glad you liked it.
Good question, I used the term “junction object” to mean that there is a many-to-many relationship between the documents and who/what they are shared with.
A ContentDocumentLink record cannot exist without both the LinkedEntityId and ContentDocumentId.
https://help.salesforce.com/articleView?id=relationships_manytomany.htm&type=0
Doug
LikeLike
Very well explained. It’s always good to understand well the underlying model. Thank you!
LikeLiked by 1 person
Thanks, Alba! Glad you liked it =)
LikeLike
Thank you! I had been able to import the ContentVersion, but not link them to the correct objects until I used a modification of your query to export the relationship information. Note that the export method, while easier, does NOT contain the information needed to link the content to the appropriate records if that’s the use case.
LikeLiked by 1 person
Erica, any chance you could write up and share the method you used to extract and correlate the ContentDocumentLink information? I’m working through the same process.
LikeLiked by 1 person
Hi David,
To my knowledge there is no way to export the ContentDocumentLink data for notes or files that have not been explicitly shared to your user.
For notes or files shared to your user, you can use Data Loader to export the ContentDocumentLink object. The
LinkedEntityId
is the the record the file is shared to (e.g. account or contact or user) and theContentDocumentId
is the note or file being shared.You can also use a complex SOQL query as depicted in the screen shot in the ContentDocumentLink Workaround section of the blog post.
In short, it’s not easy exporting the relationships, unfortunately.
Doug
LikeLike
Exporting ContentDocumentLink using DataLoader is not straightforward. You get this message:
Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id’s using the IN operator.
LikeLiked by 1 person
Agreed, John. You’ll need to use a fancy query as I described in this conversation on Success Community.
LikeLike
It is really useful. Thanks for posting such information. @Doug Ayers
I’ve been told that we cannot export notes fields from Salesforce without cut and paste.
Is this true?
LikeLiked by 1 person
Hi Jay,
Glad you found the post helpful!
You can export Note object records from Salesforce with Data Loader or the Weekly Export from Setup menu.
When you say “notes fields” do you mean text or long text fields? Those too can be exported with Data Loader.
I’m may not be understanding your question.
LikeLike
Hi Douglas,
I’m trying to convert Classic Notes to Enhanced Notes, as our company is upgrading to Lightning. We figured out we cannot bulk convert custom objects using the tool because our org has over 1000 custom objects. My plan is to export Notes from the Notes object then import them back to the ContentNotes object. Is there any way to filter this by custom object type? Also, will you be speaking at the World Tour event in Atlanta tomorrow (12-5-2018)?
Thanks
LikeLiked by 1 person
Hi Kanova,
Thanks for your interest in my notes conversion app. This app does not currently support filtering by specific object, though you may try Salesforce Lab’s Magic Mover for Notes And Attachments to Lightning Experience as I think it does provide per-object conversion options.
Sorry, I didn’t make it to the Atlanta World Tour this year but I’m hoping to attend Southeast Dreamin in March 2019!
Doug
LikeLike
Can you take the enhanced notes files downloaded into the ContentVersion and import them back into another instance on SF or do they need to be decoded? Thanks.
LikeLike
Hi Doug,
We acquired another company that was using Salesforce. I completed a Data Export of the notes and files from the new company’s org. What I need to understand is how I can map this to our current org to upload these documents to the correct records. The org of the new company has a reference to our record id where we would need these files upload. I just don’t know how and where to start to prep the files for upload.
Please provide any direction you can.
Rachel
LikeLike
I want to filter the contentdocument record which is not shared with cases.
Please provide guidance to do it.
LikeLike
Hi Doug…Thanks for this help. One question… is there a way that the actual content files in the content version folder need to be written to Salesforce? I used the export, resynced keys and meta data and loaded all of the files and notes to the new instance.
However when trying to open either the note or file, they are unreadable. Is there a setting I’m missing?
Thanks!
LikeLike
Hi Doug and thank you for this article. I do still have a question you may be able to answer for me. I am migrating content documents from one org to a new org. I see some instructions saying that the content files need to be renamed to match their Title rather than the ID as the name. I have over 100 zip files containing content, is there a way to quickly change the file names?
I will use dataloader to import. Do I need to unzip all the files and put all of the contentversion in one folder?
Thanks for any insight you can provide.
LikeLike
If you need to download the physical files with their original name and extension, ordered by their parent record name, you can use sfdx-hardis , as described in this article -> https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd
LikeLike
Hi,
Do we require any extra permissions to fetch the ContentNotes using the REST API?
LikeLike
Just an FYI, data export will not work in Sandboxes. I’ve got a full sandbox and deleted something from production inadvertently. It’s in my full sandbox but I can only get to it through a scheduled data export, not a “Export Now.” I hope this helps someone in the future!
LikeLike
When I look at the exported file I dont see the ID of the related record when following the above steps to export via data loader. In my case I am looking at notes that are only connected to the contact object but for some reason I am not seeing where the related contact is referenced. Any thoughts? Am I missing something?
LikeLike