function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brian E MillerBrian E Miller 

How do you use AttachedContentNote to get related Notes

Hi,

I'm trying to retrieve an Account's related Notes, and I came across AttachedContentNote (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_attachedcontentnote.htm).  In the doc at the bottom, it gives some usage instructions:
 
Usage
Use this object to list all ContentNote objects attached to an object.
To retrieve ContentNote objects, issue a describe call on an object, which returns a query result for each note created or attached. You can’t directly query this object.

A few questions:
  1. How do you "issue a describe call on an object, which returns a query result for each note created or attached"?
  2. How do you use the "describeSObjects()" to help in getting related records?
  3. Does anyone have an example of how to get related Notes via SOQL?  Is CombinedAttachments the only way to go?
Best Answer chosen by Brian E Miller
Brian E MillerBrian E Miller
So I found a query that works:
SELECT Id, Name, (SELECT Id, Title, TextPreview FROM AttachedContentNotes)
FROM Account
I tried this query using "AttachedContentNote" without the "s" with no luck.  For everyone else - enjoy!

All Answers

Brian E MillerBrian E Miller
So I found a query that works:
SELECT Id, Name, (SELECT Id, Title, TextPreview FROM AttachedContentNotes)
FROM Account
I tried this query using "AttachedContentNote" without the "s" with no luck.  For everyone else - enjoy!
This was selected as the best answer
Emma MayerEmma Mayer
We are trying to search an AttachedContentNote as well using REST API, but no luck. Can anyone help?
Brian E MillerBrian E Miller
Interestingly enough, an AttachedContentNote is just a wrapper on a ContentNote.  To get the actual note, you need to query ContentNote.  See the API documentation here: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentnote.htm