function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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

Michael peniaMichael penia
To add the unique record IDs of the records of the first object to the CSV file, you can use the following steps:
Identify the field that contains the unique record IDs in the first object. This field is usually called Id or Record ID.
Export the unique record IDs from the first object. You can do this using a variety of tools, such as the Salesforce Data Loader or a SQL query.
Add the unique record IDs to the CSV file. You can do this manually, or you can use a programming language such as Python or R to automate the process.

Once you have added the unique record IDs to the CSV file, you can load the data into the second object using the data loader. The data loader will match the unique record IDs in the CSV file to the unique record IDs in the second object, ensuring that the data is loaded correctly. 
best cell phone plans for college students (https://infimobile.com/student-discount)
jerry smith 39jerry smith 39
To add the unique record IDs of the records of the first object to the CSV file, you can use the following steps here https://www.clickspeedtest.info/spacebar-speed-test: