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-migrationold orgattachmentsmyfile.pdf
  • VERSIONDATA: C:sfdc-migrationold orgattachmentsmyfile.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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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-migrationold orgattachmentsmyfile.pdf
  • VERSIONDATA: C:sfdc-migrationold orgattachmentsmyfile.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)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x