I am trying to copy data from one org to a sandbox via a backup tool and SF Data loader. Most things worked fine, but ContentDocumentLinks are missing. I tried loading them via Salesforce Data Loader, authenticated with my Admin account with "View all files", "View all data" and "modify all Data" permissions. This worked for 10% of the links but most get a "invalid cross reference id" error. Taking the IDs from the CSVs, I can without problems

  • access the document and linked entity when appending it to the org url
  • take the ContentDocumentId and LinkedEntityId and create a new ContentDocumentLink with it via anonymous apex

Am I missing something? Is the data loader (and our backup tool) using different permission or sharing rules?

Further investigation showed that inserts via apex also fail - but only when inserting multiples at once. I haven't found the exact number yet, but inserting 3 at a time works, when trying inserting 130 at a time including the 3 before that, all get the error. The log shows only the insert, no triggers or anything else.

  • 1
    Does this answer your question? Migrate attachments to Salesforce Files
    – identigral
    Nov 29, 2023 at 21:15
  • ^^^ one example of how to do it. There are other Q&As on this topic, do a search.
    – identigral
    Nov 29, 2023 at 21:16
  • Do you have any custom automation on the ContentDocumentLink object? Nov 29, 2023 at 23:38
  • @identigral, this is not about attachments / files. the contentversions are there. Also, there is not automation on the contentdocumentlink. Dec 1, 2023 at 10:34


You must log in to answer this question.

Browse other questions tagged .