Paul’s Salesforce Blog

What’s new with Salesforce?

Mahmood’s Steps for Migrating Attachments to Content

Posted by paulovery on March 2, 2019

Taken from here: https://salesforce.stackexchange.com/questions/122301/migrate-attachments-to-salesforce-files

Migration – from Attachment to Salesforce Files

After a lot of RnD, came up with the following:

  1. Export Attachments data using data loader.
  2. Export Attachment files, using data export wizard or File exporter.
  3. 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.
  4. 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
  5. Upload (Insert) ContentVersion.csv.
  6. Export ContentVersion data uploaded in step-5.
  7. 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
  8. 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.

Thanks, Mahmood!

Leave a comment