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
Rinigrace MekalaRinigrace Mekala 

How to write an Apex Trigger to automatically attach files to records? Here the files are audio files that are to be attached under Notes & Attachments.

Anyone please help me in this.
Best Answer chosen by Rinigrace Mekala
RD@SFRD@SF
Rini,

I see, this is rather a daunting task :0 !!.

Developing such a trigger or code would again take up lot of your time. I suggest if its a one time thing, why dont you do a mass data upload of attachments. This would be less time consuming. 

Please, follow the link (https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/loader_attachments.htm)for mass upload of the Attachments.

Hope it helps
RD

All Answers

RD@SFRD@SF
Hello Rinigrace,

The files are external to salesforce or already into Salesforce?
Rinigrace MekalaRinigrace Mekala
Hi RD@SF,

The files are external.

Thanks
Rini
RD@SFRD@SF
Rini,

1. If the files are external, just writing a trigger wont help. The records needs to be created first and then under the notes and attachments section the file had to be uploaded.

2. I think you need a UI design such that, while creating the records itself, you can browse and select the file needs to be uplaoded.

Hope this make sense
RD
 
Rinigrace MekalaRinigrace Mekala
RD,

Thanks for your suggestion.

There is a custom object with 3000 existing records. Now, I need to upload audio files to each of these records. Going to each record and uploading file under 'Notes & Attachments' is completely a manual process and its taking more time. So I heard that we can automate this process by using a trigger. I just wanted to know how to achieve this using apex trigger.

Thanks
Rini
RD@SFRD@SF
Rini,

I see, this is rather a daunting task :0 !!.

Developing such a trigger or code would again take up lot of your time. I suggest if its a one time thing, why dont you do a mass data upload of attachments. This would be less time consuming. 

Please, follow the link (https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta/dataLoader/loader_attachments.htm)for mass upload of the Attachments.

Hope it helps
RD
This was selected as the best answer