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
Luka NićiforovićLuka Nićiforović 

SOQL query to get related files and notes for an object

I'm trying to get related Files and Notes of objects in Salesforce, this is the UI representation of what I want to get:
User-added image

So far I've tried these queries:
SELECT Id FROM Attachment WHERE ParentId='{objectId}'
SELECT Id FROM Note WHERE ParentId='{objectId}'
But the results are empty arrays..

Does anyone know a way to get this data, at least the count of related files and notes?

Best Answer chosen by Luka Nićiforović
Niranjana Ramanathan 3Niranjana Ramanathan 3
For querying the No of files related to a particular record.
Try this:
[SELECT Id, LinkedEntityId, ContentDocumentId,Visibility, IsDeleted, ShareType,ContentDocument.Title,ContentDocument.createdDate, ContentDocument.FileType FROM ContentDocumentLink WHERE LinkedEntityId =:parentIds];