[SalesForce] Notes & Attachments Cant find using soql

I did not get any result from querying notes and attachment.

Setup
I create a custom object. I added notes and attachment to the custom object
I created soql that filter by parentId and it looks like this.

I created a record on the custom object named 'record1', and on the related tab, I upload notes and attachments named attachment1.

I created a query that looks like this

Select name from attachment where parentId =:(record1 Id);

same with note

Select title from Notes where parentId =:(recordthe 1 Id);

result is 0 record.

Best Answer

In Spring'16 release Salesforce introduced Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments in Salesforce Files Settings:

Files that you upload to the Notes & Attachments related list on records in Salesforce Classic are now Salesforce Files objects, rather than the old attachment objects. A new org pref in Salesforce Files Settings controls this behavior, and is enabled by default for new orgs.

The following SOQL query would allow you to get Ids of Files (Attachments) and New Notes related to the record

SELECT ContentDocumentId,Id,LinkedEntityId,ShareType 
FROM ContentDocumentLink WHERE LinkedEntityId = 'YourRecordId'
Related Topic