Pages

Tuesday, September 24, 2013

Salesforce: Mass Upload files to Attachment using Data Loader


Background: user need to mass upload files as attachment in Account or Opportunity.

Solution: Using Data Loader to mass upload files to attachment. If you need to regularly do mass upload, you can schedule Data Loader, see this user guide.

For loading file as Files (not as Attachment), check this blog Mass Upload files to Files using Data Loader.

1. Prepare CSV file
You can use Ms Excel to create new CSV file with following columns:
  • ParentId - Id of the record to which the attachment should be associated 
  • Name - Name of the attachment (you can put file name here)
  • ContentType - Format of the extension (e.g. image/jpeg, application/vnd.ms-excel, etc), if you not sure, you can run SOQL query to Attachment object for similar file type. However, this field is not mandatory, so you can leave it blank or un-map it.
  • OwnerId - Id for the owner of the attachment (UserId). If you not put any UserId here, your UserId will be OwnerId
  • Body - File path to the attachment on the local machine (C:\temp\how to make gold.png)

2. Login to Apex Data Loader
  • Select the "Insert" button. 
  • In the 'Select Salesforce Object' window, select the 'Show all Salesforce Objects' checkbox and then select "Attachment". 
  • Choose the CSV file you have prepare above. 
  • In the mapping step, map the following fields:


Click "OK" to proceed with the insert. It may take a few minutes depends on the number of file and file size, but the attachments should be successfully uploaded to your Salesforce.

Hope this help.

3 comments:

  1. Thanks for the details. i was able to follow the steps and update the document. But only problem the pfds are not readable. It appears in a strange format.

    Looks something like this -
    %PDF-1.5
    1 0 obj
    <>
    endobj
    2 0 obj
    <>
    endobj



    ReplyDelete

Page-level ad