I have created two custom objects (A and B)and a junction object(AB). i.e. Both A and B have Many to Many relationship. Now I need to insert 5000 records. How can I automatically populate the relation in Junction object. DO I have to write any trigger or Do I have to do Manually mapping the records?
Best Answer
The best way to achieve this is by using the data loader. I would recommend using www.dataloader.io since it is infinitely easier to use and it contains a nifty feature that will make your life easier.
Dataloader.io allows you to "lookup" related records based on a certain field, so for example:
Say you wanted to create an account via dataloader and wanted to set the OwnerId field, but you only have the email of the user you want to be set as the owner. You can configure Dataloader.io to actually do a lookup of the user id based on the email, saving you the extra step of massaging the CSV.
To be more specific to your example, I would:
You can read about how to use the lookup feature here: https://dataloader.io/using-import-lookups
Hope this helps!