Wednesday, March 28, 2012

Inserting/Import Attachments using Apex Dataloader in Salesforce


Once I came to know we can able to extract the Notes and attachments from an object using Dataloader, I thought importing the attachment is also the same and we can do it very easily in the same manner but I was wrong.


Let us see how we can do this using dataloader,but before that please recall How to Import/Export Notes and Attachment through DataLoader in Salesforce

For importing or inserting an attachment to an object (say Account) we need the following details in the CSV file that we are going to use in the Data loader.

PARENTID
NAME
CONTENTTYPE
BODY
OWNERID


PARENTID:
This is nothing but the Salesforce ID of the Parent object record(Say AccountID).

NAME:
Name is the name of the attachment file.

CONTENT TYPE:

The File Format eg: Doc,txt,xls,pdf..

BODY:
This one plays an important role while importing an attachment.
We must give the Path of the attachment in the local Machine.
Make sure the File must follow with its extensions i.e .pdf,.doc.xls, etc

Example: C:\Program Files\salesforce.com\Data Loader\Test1\Attachments\TestDoc.doc


OWNERID:

The user Profile.

 After filling up all these details in the CSV file load this file in data loader and Map the respective fields and Insert the file into Salesforce with Dataloader.

5 comments:

  1. Hi Satheesh,
    As i was trying to load the data in to SFDC for attachment object i was getting the below error:
    Error converting value to correct data type: E:\export\attach.xls (The system cannot find the file specified)
    I have checked the file vice versa ie both the template and the name of the template in csv file are obsolutely correct and fields matching is also done with no ambiguity..


    ReplyDelete
    Replies
    1. Hi Ramesh,

      You need to attach a csv file not an xls file. Please upload a csv file.

      Delete
  2. Hi,
    I tried to import to Salesforce(cloud) with the BODY as a local path on my computer or only \FILENAME.DOC but I'm getting the same error "SOURCE: 'Body' DESTINATION: 'Body' ERROR:Required fields are missing: [Body]"

    ReplyDelete
    Replies
    1. Hi Daniel,
      You need to specify the whole path of the file from your machine not the file name alone.

      Delete
  3. Hi Daniel,
    what about uploading attachments to Accounts, using External ID and not the ParentID ? do you have same suggestions ?
    many thanks

    ReplyDelete