+ Start a Discussion
Hugo CostaHugo Costa 

Query of "View All Notes Page"


Can anyone tell me the query to get the same results from “View All Notes & Attachments” page?
The idea is to find the object that saves the attached files in a comment chatter.
Nowadays if you put one attach on a comment you cannot find them by query.
Best regards,
Hugo Costa

Wondering if below query is helping you:
select id, Name,
  (SELECT Title, ContentDocumentid FROM AttachedContentDocuments),
  (Select Id, IsNote, Title From NotesAndAttachments)
   from Account where id = <record-id>
You can also use get same results using single inner query on "CombinedAttachment" table.

Updated query will look like:
select id, Name,
            (Select Id, ParentId, RecordType, Title, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, FileType, ContentSize, FileExtension, ContentUrl From CombinedAttachments)
      from Account where id =<record-id>

As per document (link (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_combinedattachment.htm)):
Use this object to list all notes, attachments, documents uploaded to libraries in Salesforce CRM Content, and files added toChatter for a record, such as a related list on a detail page.