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
ozhereozhere 

How to grab all attachments

Hi,

 

I am trying to get all attachments via SOQL query: "SELECT Name,Id, ParentId,Body  FROM Attachment".

But above query returns only one record. 

If I remove the Body from the query (SELECT Name,Id, ParentId  FROM Attachment), I get all attachment records.

Is there a way to grab all attachments with Body via SOQL???

 

Thanks

-O

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
you have to use queryMore to fetch the remaining results, see the api docs for details.

All Answers

SuperfellSuperfell
you have to use queryMore to fetch the remaining results, see the api docs for details.
This was selected as the best answer
ozhereozhere

Thank you, SimonF!

 

When I query attachments with Body in query, the response returns every field as a separate record.

 

So when I $query = "Select a.Body, a.Id, a.LastModifiedDate, a.Name, a.ParentId, a.SystemModstamp from Attachment a";

 

foreach ($response->records as $record) {  

      print_r($record);
      echo "<br/>";       
                            
}

 

I get Body value, then Id value, etc., instead of stdClass Object.  Do you know how to avoid this and get whole  attachment record as stdClass Object??

 

Thank you!

-O