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
Nidhi Sharma 13Nidhi Sharma 13 

Creating relationship between 2 objects while importing data in Salesforce

Hi,

I am trying to import data from a csv file to multiple objects in a single action. My csv file is like this..

S.No.      Column 1      Column 2
               (Parent)       (Child)
1.             A1              -
2.             B1              A1
3.             C1              B1
4.             D1              A1

So, in a way, B1 and D1 are child of A1 and C1 is child of B1

Now I have traversed all csv lines to creat 4 records for A1, B1, C1 & D1 and fetched them in a list. Now I have a parent field in each record named 'Parent Id' which should be null, Id of A1, Id of B1, Id of A1 respectively. I don't want to go with matching names for records because the names might repeat and the code might find 2 records with same name and won't work. But how to fetch the ids in correct places then? Do I need another column to uniquely identify them? What to do?