How would you insert multiple records into the junction object?
I have the following Junction object name (Associate_Employee__c
)
with the following fields:
Employee_Request__c
Employer_Request__c
both are master_detail relationship
List<Associate_Employee__c> aeList = new List<Associate_Employee__c>();
List<Employee_Request__c> empList = new List<Employee_Request__c>();
List<Employer_Request__c> emplorList = new List<Employer_Request__c>();
Associate_Employee__c pa = new Associate_Employee__c();
Employee_Request__c empReq = new Employee_Request__c();
//record 1
empReq.Project_Name = 'SFDC1';
empList.add(empReq);
//record 2
empReq = new Employee_Request__c();
empReq.Project_Name = 'SFDC2';
empList.add(empReq);
insert empReq; //INSERT
aeList.Employee_Request__c = empReq.id; // ??? How can I reference? If you got multiple records?
same goes with the other object Employer_Request__c