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
Andre Baxter 7Andre Baxter 7 

My Attachment soql query is returning zero rows despite having Attachments in the org


I have tried a few different methods to query for the Attachments in my org, but zero rows are always returned.
I ran this query in the query editor in dev console, but zero rows were returned:

select id, name from Attachment

The same result occurred when I ran below code in the execute anonymous window:

for (Attachment [] atts : [select name from attachment]) {
// do something with atts system.debug
( atts.size() );
}

I'm expecting at least two rows to be returned on a Opportunity record that I'm using for testing. Is there something on the configuration end that I need to set up so that I'll be able to retrieve the attachments via soql? I'm guessing that there's something simple that needs to be tweaked that I overlooked.
Best Answer chosen by Andre Baxter 7
Andre Baxter 7Andre Baxter 7

I received my answer from another source.  Since I'm working on a newer org, the attachments are likely uploaded as Files, which can be accessed from the ContentVersion system object:
SELECT Id, Title, VersionData FROM ContentVersion