ContentNote
ContentNote
Represents a note created with the enhanced note-taking tool, released in Winter ’16.
This object is available in API version 32.0 and later.
Supported Calls
create(), delete(), describeLayout(), describeSObjects(), query(), retrieve(), search(), update()
Special Access Rules
- Notes must be enabled.
Fields
| Field | Details |
|---|---|
| Content |
|
| ContentModifiedDate |
|
| ContentSize |
|
| ContentSizeLong |
|
| FileExtension |
|
| FileType |
|
| IsReadOnly |
|
| LastViewedDate |
|
| LatestContentId |
|
| LatestPublishedVersionId |
|
| OwnerId |
|
| SharingPrivacy |
|
| TextPreview |
|
| Title |
|
Usage
- Use ContentNote to create, query, retrieve, search, edit, and update notes.
- ContentNote is built on ContentVersion, and so it has many of the same usages.
- Not all fields can be set for notes. Only the Content and Title fields can be updated.
- The maximum file size that you can upload via the SOAP API is 50 MB. When a document is uploaded or downloaded via the API, it’s converted to base64. This conversion increases the document size by approximately 37%. Account for the base64 conversion increase so that the file you plan to upload is less than 50 MB after conversion.
- You can convert old Note records to Lightning Experience, so users can view and edit notes from the Notes & Attachments related list in Lightning Experience. Users can edit their converted notes, which are accessible from the Notes related list and Notes tab. Copy old Note records to newly created ContentNote records. Users assigned the Set Audit Fields Upon Creation permission can set the owner, created date, and last modified date on ContentNote records.
- SOQL and SOSL queries on the ContentNote return only the most recent version of the note.
- To relate a note to a record, use ContentDocumentLink. Review the LinkedEntityID field in ContentDocumentLink for a list of objects that notes can relate to.
For example, the following Apex code creates a note and escapes any special characters so they’re converted to their HTML equivalents.
1ContentNote cn = new ContentNote();
2cn.Title = 'test1';
3String body = 'Hello World. Before insert/update, escape special characters such as ", ', &, and other standard escape characters.';
4cn.Content = Blob.valueOf(body.escapeHTML4());
5insert(cn);In this example, the following code creates a note using text that is already formatted as HTML, so it doesn’t need to be escaped.
1ContentNote cn = new ContentNote();
2cn.Title = 'test2';
3String body = '<b>Hello World. Because this text is already formatted as HTML, it does not need to be escaped.
4Special characters such as ", etc. must already use their HTML equivalents.</b>';
5cn.Content = body;
6insert(cn);