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
David SomekhDavid Somekh 

Accsessing attachments using Apex

Hello Apex experts!

 

I need to be able to get the link of an attachment and download the file to a diffrent server. On the record that has the attachment, I need to have a button that triggers this.

 

Is there some way to loop all the attachments in the record?

 

 

Thanks,
David

littledevillittledevil

Hi,

 

Is your problem resolved? If not:

 

1) Salesforce stores all the attachments under object "Attachment"

2) So, in your apex code you can iterate on these attachments.

 

e.g List<Attachment> lstAttachments = [Select Id,Body,ParentId from Attachment where ParentId : = {Your record Id}];

 

This should give you all the attachments related to your record.

 

Sheetal