+ Start a Discussion
ntnngntnng 

Using Data Loader to load records into object with master details relationship

Hi,

 

I need to load data into two objects. I am able to load data into one object using the data loader. The second object has a master-details relationship with the first object so I need to have the unique record id of the records of first object in the CSV file. How can I add those record id's to my CSV file?

Best Answer chosen by Admin (Salesforce Developers) 
sales4cesales4ce

If in a Master-detail relationship, you first need to insert all master records.

Then run a report to get all the Inserted Master record Id's and export them your machine.

 

Now to insert detail object records, you need to associate them with Master Record ID.

A possible approcah would be use VLOOkUP function in Excel to populate the Id's.

 

Once you have the ID's populated then you can insert Detail records using data loader.

 

Hope it helps.

 

Sales4ce

All Answers

sales4cesales4ce

If in a Master-detail relationship, you first need to insert all master records.

Then run a report to get all the Inserted Master record Id's and export them your machine.

 

Now to insert detail object records, you need to associate them with Master Record ID.

A possible approcah would be use VLOOkUP function in Excel to populate the Id's.

 

Once you have the ID's populated then you can insert Detail records using data loader.

 

Hope it helps.

 

Sales4ce

This was selected as the best answer
Pradeep_NavatarPradeep_Navatar

When you import the data using dataloader, it generates a success file. Open that file and you will be able to see an extra column where you will find the salesforce ids related to the each record. You can map these ids on the second objects csv file using vlookup.

 

Hope this helps.

 

sales4cesales4ce

That was cool! I did not know that before.

It definitely helps to reduce the task running reports and exporting them.

 

Sales4ce

FilipeMFilipeM

I used Pentaho Kettle to achieve this and decided to share.

 

1) As a source, select Salesforce Input to get the name-id lookup table (using a soql query) and

2) select Stream lookup to transform a Name (for example) in an Id, the same result you'd get with VLOOKUP using Excel

 

The query was written to simply retrieve all results (probably there's a better way to do it):

 

select obj.id, obj.Name from Object__c obj

 

As for the Stream Lookup just select the Salesforce Input as Lookup step.

 

Cheers,

Filipe

Volunteer

Amnesty International Portugal