4

One of our clients has a requirement to migrate attachments to Salesforce Files.

enter image description here They have also enabled this option from Winter '16 to allow file uploads to goto salesforce files instead of attachments.

enter image description here

How can I migrate from attachments to more sophisticated sharing and content versioning salesforce files feature?

  • I believe you do this by creating ContentVersion - that is a child of ContentDocument. See nifty utility (Windows only) FileExporter that can be of assistance appexchange.salesforce.com/… – cropredy May 19 '16 at 4:46
  • @cropredy: What you suggests mean that I should have ContentDocument record already present, so it will allow me to have its versions. The problem I have at hand is I can't insert records into ContentDocument. Do I make sense? – Mahmood May 19 '16 at 7:01
  • 2
    Inserting a contentversion automatically creates the contentDocument. – cropredy May 19 '16 at 14:52
  • Ok. I shall give it a try and let you know. – Mahmood May 19 '16 at 15:03
  • @cropredy: I tried loading data via ContentVersion, and it does create ContentDocument. But the problem is still stands. for example, lets say, abc.txt was attached to ABC contact. To relate this attachment to contact after "File" migration would be to use ContentDocumentLink. Which means that I have to first load data into ContentVersion, then export ContentDocument, use Vlookup to update the "LINKEDENTITYID" field in CSV and then upload this new csv into ContentLinkDocument. Please let me know if i have jot-down the steps correctly or is there a better way of migration. – Mahmood May 20 '16 at 12:52
5

FYI Douglas Ayers has a package for automating this via Apex: https://douglascayers.com/2015/10/10/salesforce-convert-attachments-to-chatter-files/

  • Nice! My solution gives an in-depth knowledge for the techies to know how salesforce files and enhanced notes work but this solution is very nifty and for those who don't want to get into the nitty gritty of this migration. – Mahmood Dec 13 '16 at 14:42
4

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.

  • This is great @mahmood but when you upload the notes and attachments to new Files you lose the history of when they were created an who by. We are looking for a solution that allows us to migrate relevant historical data in notes/attachments into the new Files. We have turned on the create Attachments as Files so any new additions we do not have to be concerned about. – iamjury Feb 16 '17 at 22:29
  • To manage historical data from other org or objects, you need to create CustomObject and hold the history for your relevant object. And then display it as a related list or may be create a report for your users to view. A more detailed analysis on the same topic can be found here. – Mahmood Feb 17 '17 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.