---
schema_version: "1"
id: f5c12f29bc38530fa7401a89a70615292a2a77c7d87249b5e7f8b4855946da9c
title: ContentNote
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_contentnote.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentnote.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9a4e66a4c7ea951ec7fbade43c96664c0ff7a9b5f6f08dbd30c39d8cca80c3a0
description: 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.
---
# 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 | 
Type

base64

Properties

Create, Nillable, Update

Description

The content or body of the note, which can include properly formatted HTML or plain text. When a document is uploaded or downloaded via the API, it must be base64 encoded (for upload) or decoded (for download). Any special characters within plain text in the Content field must be escaped. You can escape special characters by calling content.escapeHtml4(). If the input contains unsafe HTML characters or new lines, we automatically strip them out before saving the content.



 |
| ContentModifiedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The date the document was modified. ContentModifiedDate updates when, for example, the document is renamed or a new document version is uploaded.

This field is available in API version 48.0 and later.





 |
| ContentSize | 

Type

int

Properties

Filter, Group, Nillable, Sort

Description

The size of the note in bytes for notes smaller than 2 GB. In API version 66.0 and later, use the ContentSizeLong field.



 |
| ContentSizeLong | 

Type

long

Properties

Filter, Group, Nillable, Sort

Description

The size of the note in bytes, up to 10 GB.

This field is available in API version 66.0 and later.





 |
| FileExtension | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

File extension of the note.



 |
| FileType | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

Type of file for the note. All notes have a file type of SNOTE.



 |
| IsReadOnly | 

Type

boolean

Properties

Defaulted on create, Group, Sort

Description

Indicates whether the note is read only.



 |
| LastViewedDate | 

Type

dateTime

Properties

Filter, Nillable, Sort

Description

The date the note was last viewed. This field is available in API version 35.0 and later.



 |
| LatestContentId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

Lookup to the note's ContentBody. This field is available in API version 52.0 and later.

This is a relationship field.

Relationship Name

LatestContent

Relationship Type

Lookup

Refers To

ContentBody



 |
| LatestPublishedVersionId | 

Type

reference

Properties

Filter, Group, Nillable, Sort

Description

ID of the ContentVersion for the latest published version of the note.



 |
| OwnerId | 

Type

reference

Properties

Create (for users assigned the Set Audit Fields Upon Creation permission), Defaulted on create, Filter, Group, Sort, Update (for users assigned the Set Audit Fields Upon Creation permission)

Description

ID of the owner of the note.



 |
| SharingPrivacy | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Restricted picklist, Sort, Update

Description

Controls sharing privacy for a file. Only Salesforce admins and file owners with Collaborator access to the file can modify this field. Default is Visible to Anyone With Record Access. When set to Private on Records, the file is private on records but can be shared selectively with others.

This field is available in API versions 41.0 and later.





 |
| TextPreview | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

A preview of the note’s content. This field is available in API version 35.0 and later.



 |
| Title | 

Type

string

Properties

Create, Filter, Group, idLookup, Namefield, Sort, Update

Description

Title of the note.



 |

## 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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentdocumentlink.htm "Represents the link between a Salesforce CRM Content document, Salesforce file, or ContentNote and where it's shared. A file can be shared with other users, groups, records, and Salesforce CRM Content libraries. This object is available in versions 21.0 and later for Salesforce CRM Content documents and Salesforce Files."). Review the LinkedEntityID field in [ContentDocumentLink](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentdocumentlink.htm "Represents the link between a Salesforce CRM Content document, Salesforce file, or ContentNote and where it's shared. A file can be shared with other users, groups, records, and Salesforce CRM Content libraries. This object is available in versions 21.0 and later for Salesforce CRM Content documents and Salesforce Files.") 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.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

Apex code doesn’t need to be encoded to base64 before it’s uploaded and downloaded.

ContentNote cn = new ContentNote();
cn.Title = 'test1';
String body = 'Hello World. Before insert/update, escape special characters such as ", ', &, and other standard escape characters.';
cn.Content = Blob.valueOf(body.escapeHTML4());
insert(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.

ContentNote cn = new ContentNote();
cn.Title = 'test2';
String body = '<b>Hello World. Because this text is already formatted as HTML, it does not need to be escaped. 
Special characters such as &quot;, etc. must already use their HTML equivalents.</b>';
cn.Content = body;
insert(cn);