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
Chelsea LukowskiChelsea Lukowski 

Copy attachment to unrelated object

I am wanting to copy an attachment from one object to another and then delete the attachment from the orignial record once it is copied.  These objects are not related in any way. I know I need a trigger to accomplish this. I have an integration process that uploads attachments to an object called PDF_Uploader__c, this is a place holder. When the attachment is created under the Notes & Attachments section, a record is created under AS400_Report__c using the attachment name as the record Name, when this happens I would like the attachment to also copy from PDF_Uploader_c to the new AS400_Report__c record. Then delete the attachment from PDF_Uploader__c. The attahcment names are unique. Any suggestions?????
UC InnovationUC Innovation
Hi Chelsea,

This thread should help you.

https://developer.salesforce.com/forums/?id=906F00000008zRaIAI

The only thing you probably need to change is the attachment query WHERE clause to look for attachment names equal to the AS400_Report__c records that fired the trigger on insert. And you probably need to bulkify the trigger.