0

We have a custom object. In the notes and attachments related list of this custom object we have uploaded few pdf and ms-word files (each of them of size < 5 mb) we are not able to access the attachments by soql query inside apex class.

Further even in workbench a simple query 'SELECT Id, Name FROM Attachment' returns 0 records.

6
  • Did you save as attachment or as chatter feed item? Try 'Select Id, ContentFileName From FeedItem'. Commented Apr 18, 2016 at 10:50
  • 1
    We saved it as attachment. We added a note as well and uploaded it. For testing, we added a note to the same object and the query SELECT Id, body FROM Note returned the record. But still no luck with attachments
    – Nishant
    Commented Apr 18, 2016 at 11:34
  • I've never seen that before. This works fine for me. You didn't mark the attachments as 'private', did you? Commented Apr 18, 2016 at 15:31
  • Try SELECT ContentDocumentId,Id,LinkedEntityId,ShareType FROM ContentDocumentLink WHERE LinkedEntityId = 'YourRecordId' it's possible you have Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments enabled for your org.
    – o-lexi
    Commented Apr 18, 2016 at 16:35
  • Thanks Oleksiy. You are correct. In our org, the files uploaded to the attachments related list were uploaded as salesforce files. We unchecked the check-box and now the query works fine.
    – Nishant
    Commented Apr 18, 2016 at 19:13

1 Answer 1

3

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'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .