You need to sign in to do that
Don't have an account?
asadim
Moving Attachment across parents
Hi,
We have thousands of attachments that we want to associate to new parents. Exporting them using Data Loader and loading them into Access/Excel will cause bad data imports (data is delimited incorrectly or the Office tool won't be able to open them). In Apex you can't overwrite the parentId field.
What's the solution? Any ideas? Thanks!
In Apex you can do cloning the Attachment record and then delete the original record. Its not possible to update ParentId field. bulk cloning will not be possible as Salesforce has Governor limit on the heap size. Best option will be using the Salesforce API with .NET or JAVA and writing a custom logic.
All Answers
In Apex you can do cloning the Attachment record and then delete the original record. Its not possible to update ParentId field. bulk cloning will not be possible as Salesforce has Governor limit on the heap size. Best option will be using the Salesforce API with .NET or JAVA and writing a custom logic.
Thanks. Why would the heap size limit cause an issue? Can't I write a Batchable class that processes the attachments? Maybe I'm not clear on the heap size limit (it's 6MB for batches).
Heap size will exceed in the case of cloning the attachments of more than 4MB in that case. After you make a clone, heap will be containing two records of 4MB files. I never tried this in batch Apex, but in the trigger it does create a heap size limit reached exception.
Batch size of 1 should solve the heap size problem.
Thanks.