Additional detail
How to import data into a related list using the dataloader
The dataloader can be used to import data into a custom object that has a lookup or master child relationship to a parent object.
Often this is done to import order or invoice data into a related list on an account, or bank account data on a related list to a client. However, this procedure can be applied to any object and its related list.
To import data, and have it related to a parent object, there are a few requirements.
Setup your import file
- The import file must have a column for the identifier of the parent object that each imported record should be attached to.
In the case of importing orders and attaching them to accounts, the import file of order records should have fields for all the order data, as well as a field that identifies the account to which this order is related. This field should not be the name of the account/parent record. It is best if this is a number, or mix of numbers and text. This will most likely already be defined for you. You may have to work with the administrator of the system this data is coming from to provide this ID number in the import file.
- Also, make sure the file is saved as a CSV file (standard format that Excel files can be saved to, and that any database administrator can produce easily)
Setup the parent object:
- Create a custom field on the parent object called Account ID, or Account Number, or something similar. Set the External ID field property for this field.
Setup the parent record data in salesforce.com.
- You will then need to map the ID numbers in the source system, which are in the import file, to the parent records in salesforce.com.
Setup the child object (the one that will appear as the related list):
- Create a custom field called “Account Number”, in addition to the fields you plan to import.
Import the data using the Dataloader
- Start the data loader
- Start an Upsert operation
- Enter your salesforce login credentials
- When login succeeds, click the Next button
- Choose the target object, into which you want to import the data
- Choose the CSV file to import
- The next screen, Step 2a in the wizard, can’t be changed. Click Next
- Step 2b, choose the custom External ID field you created
- Step 3: Create a field map, or choose one you have already saved.
- Drag salesforce field names from the top section of the screen, down to the bottom half, where the .csv file column headers are listed.
- Drag the field with a name format like named Account__r:AccountID__c down to match the name of the column that is your reference column in the import file.
- Click Next
- Step 4: Choose the directory where success and error logs will be saved.
- Click Finish
At this point, a popup will appear indicating how many rows were successfully imported. If you get error, choose to see the errors, and scroll all the way to the right and look at the error message to troubleshoot.
If you make a mistake, you can delete your bad data using the dataloader as well. Just delete the data using the successlog files, and start again.