I need to upload some 2000 documents to specific users in salesforce. I have a csv file that has the Salesforce-assigned ContactID, as well as a direct path to the files on my desktop. Each contact's specific file url has been included in the csv. How can I upload them all at one and, especially, to the correct contact?
Mass Upload Files To Specific Contacts Salesforce
3.5k Views Asked by Ethan At
2
There are 2 best solutions below
0
On
Your CSV should contain following fields : - ParentID = Id of object you want to link the attachment to (the ID of the contact) - Name = name of the file - ContentType = extension(.xls or .pdf or ...) - OwnerId = if empty I believe it takes your user as owner - body = the location on your machine of the file (for instance: C:\SFDC\Files\test.pdf
Use this csv to insert the records (via data loader) into the Attachment object. You will then see for each contact, that records have been added to the 'Notes & Attachments' related list.
You indicated in the comments / chat that you want it as "Files".
The "Files" object is bit more complex than Attachments, you'll need to do it in 2-3 steps. What you see as a File (you might see it referred to in documentation as Chatter Files or Salesforce Content) is actually several tables. There's
ContentDocumentwhich can be kind of a file header (title, description, language, tags, linkage to many other areas in SF - because it can be standalone, it can be uploaded to certain SF Content Library, it can be linked to Accounts, Contacts, $_GOD knows what else)ContentVersionwhich is well, actual payload. Only most recent version is displayed out of the box but if you really want you can go back in timeThe crap part is that you can't insert
ContentDocumentdirectly (there's no create() call in the list of operations) .Theory
So you'll need:
ContentDocumentLinkrecords that will connect Contacts and their PDFsPractice
This is my C:\stacktest folder. It contains some SF cheat sheet PDFs.
Here's my file for part 1 of the load
Fire Data Loader, select Insert, select showing all Salesforce objects. Find ContentVersion. Load should be straightforward (if you're hitting memory issues set batch size to something low, even 1 record at a time if really needed).
You'll get back a "success file", it's useless. We don't need the Ids of generated content versions, we need their parents... Fire "Export" in Data Loader, pick all objects again, pick ContentDocument. Use query similar to this:
You should see something like this:
Use Excel and magic of VLOOKUP or other things like that to link them back by title to Contacts. You wrote you already have a file with Contact Ids and titles so there's hope... Create a file like that:
1st column is the file Id, then contact Id, then some black magic you can read about & change if needed in
ContentDocumentLinkdocs.Load it as insert to (again, show all objects) ContentDocumentLink.
Woohoo! Beer time.