Migration - from Attachment to Salesforce Files
After a lot of RnD, came up with the following:
- Export Attachments data using data loader.
- Export Attachment files, using data export wizard or File exporter.
- Create two fields, ParentId and AttachmentId on ContentVersion object
- ParentId will hold the id of the entity, attachment was linked to.
- AttachmentID (with unique constraint) will hold the id of the attachment from attachment object.
- Create a CSV, ContentVersion_upload.csv, for ContentVersion with the following fields
- Attachment_id (AttachmentId from file exported in step-1)
- ISDELETED
- PARENTID (Entity Id of the object, from file exported in step 1)
- Versiondata (local file path)
- PathOnClient (local file path)
- Title (title of the file)
- OWNERID
- DESCRIPTION
- Upload (Insert) ContentVersion.csv.
- Export ContentVersion data uploaded in step-5.
- Create another CSV for ContentDocumentLink (and update ContentDocumentID and ParentEntityId, from the ContentVersion file exported in step-5) with the following fields:
- CONTENTDOCUMENTID (ContentDocumentId from file exported in step-6)
- LINKEDENTITYID (ParentId from file exported in step-6)
- SHARETYPE
- VISIBILITY
- Upload (Insert) ContentDocumentLink.
I, also, migrated legacy notes to Enhanced Notes . For a complete tutorial on migration of both Notes & Attachments to Files and Enhanced notes please refer to this blog that I created.
ContentVersion
- that is a child ofContentDocument
. See nifty utility (Windows only) FileExporter that can be of assistance appexchange.salesforce.com/…