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
Emil Mr No regression DoverlindEmil Mr No regression Doverlind 

Best practice to migrate attachment records to Salesforce files?

What would be best practice for migrating attachment records to Salesforce files when parent record object does or does not have feed tracking on?
JeffreyStevensJeffreyStevens
Migrating from where?  If they are stored on your PC - then dataloader.
Emil Mr No regression DoverlindEmil Mr No regression Doverlind
Sorry, most orgs now have a lot files as Attachment records. e.g. List<MyCustomObject__c> myCustomObjectList = [SELECT Id, (SELECT Id, Name, Body, ParentId FROM Attachments) FROM MyCustomObject__c];. Now I would like to migrate them to Salesforce files by code, which as I understand is based on the ContentVersion object, but how would I associate that ContentVersion with the parentId of the Attachment record? And I guess there would be to cases for this, one where feed tracking is on for the parent object of the Attachment record and one where feed tracking is off for the parent object of the Attachment record.