Loading

Perform SOQL query on all enhanced notes records

Veröffentlichungsdatum: Jun 22, 2026
Beschreibung

When performing a SOQL (Salesforce Object Query Language) query on Enhanced Notes in Salesforce, a user may be able to view a note in the Salesforce UI but cannot retrieve it when querying the ContentNote object without a WHERE clause.

Key Objects:

  • ContentNote — Salesforce's Enhanced Notes object, used to store rich-text notes linked to records
  • ContentDocument — the parent object for all Salesforce files and notes stored in the content library

This behavior occurs because note visibility in the UI is inherited from the parent record's sharing settings. However, SOQL queries on ContentNote and ContentDocument follow Content sharing rules, which are separate from record-level sharing. A user can query a specific note by its record ID using a WHERE clause, but a broad query without a WHERE clause returns only notes where the user has been explicitly granted Viewer or Collaborator sharing access.

Select Id from ContentNote where id = '069xxxxxxxxx';
Select Id from ContentNote;
Lösung

Root Cause

The Enhanced Note's Content Sharing settings are not configured to grant the querying user Viewer or Collaborator access. This is why the note is visible in the Salesforce UI (via parent record access) but absent from unrestricted SOQL queries on the ContentNote object.

Resolution Steps

  1. Open the Content Note in the Salesforce UI
  2. Navigate to the Sharing Settings for the note
  3. Change the sharing setting to Viewer or Collaborator for the intended user or running user
  4. Re-run the SOQL query on ContentNote without a WHERE condition — the previously missing record will now appear in the results
Select Id from ContentNote;

Note: Salesforce Administrators cannot change Content Note Sharing Settings via API, so it may not be possible to update sharing settings for large volumes of notes programmatically.

Alternate Approach for Bulk Data Export

For bulk data export scenarios such as data backup or migration, use the "Export All" option rather than attempting to query all ContentNotes through Data Loader. Sharing restrictions on ContentNote will prevent complete retrieval via SOQL when querying without a WHERE clause.

    Nummer des Knowledge-Artikels

    000384917

     
    Laden
    Salesforce Help | Article