[SalesForce] Migrating Chatter files attached to feed comments

I am ultimately trying to use data loader to migrate our chatter posts & comments that have files attached to them. They were originally added by uploading directly from computer to the comment. It looks like API version 36 and above, you are supposed to use the ContentVersion object to insert a new file, and then make references to them using the FeedAttachment object.

I've already migrated the users, collaborationGroups, collaborationGroupMembers, FeedItems and am stuck with getting the FeedComments that have files attached.

When I am inserting the ContentVersion objects, I would like to retain the original document properties and list the ownerID as the original user with their new cross referenced ID. However, I keep getting the following error: Documents in a user's private library must always be owned by that user.

If I leave the ownerID blank, it defaults to my id but successfully inserts into the new org.

This is an example of the data I'm inserting.

  • OWNERID: 005o0000002DMoTXXW
  • TITLE: title of file
  • PATHONCLIENT: C:\sfdc-migration\old org\attachments\myfile.pdf
  • VERSIONDATA: C:\sfdc-migration\old org\attachments\myfile.pdf
  • DESCRIPTION: description of file
  • ORIGIN: H

Questions:

  1. Am I able to set the owner ID to the original owner?
  2. If I insert with my own ID, am I able to easily update to the correct owner in a subsequent step?
  3. Is there an easy way to upload the file directly with the comments? In 35 and before, you can upload the files directly with the feedItem object, but it doesn't look like that is possible with feedComments?

Best Answer

I was able to work around this by inserting new ContentVersion with the following:

  • OWNERID: 005o0000002DMoTXXW (my id, or believe you can omit)
  • TITLE: title of file
  • PATHONCLIENT: C:\sfdc-migration\old org\attachments\myfile.pdf
  • VERSIONDATA: C:\sfdc-migration\old org\attachments\myfile.pdf
  • DESCRIPTION: description of file
  • ORIGIN: H

Then do a subsequent update on the ContentDocument object with:

  • ID: 069g0000000GOayAAG (resulting document id from insert)
  • OWNERID: 005o0000002DMoTAAW (correct owner ID)