Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Created June 7, 2019 09:39
Show Gist options
  • Save swapnilshrikhande/604cc4b909c26b338b2d8163edb54809 to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/604cc4b909c26b338b2d8163edb54809 to your computer and use it in GitHub Desktop.
Relationship without external id
// List<List<Contact>>
Contact contactR1 = new Contact(LastName='Test1');
Contact contactR2 = new Contact(LastName='Test2');
List<Contact> contactList = new List<Contact>{
contactR1,contactR2
};
insert contactList;
Relationship__c relation = new Relationship__c(
Parent_Contact__c = contactR1.Id
,Child_Contact__c = contactR2.Id
);
List<SObject> sobjectList = new List<SObject>{
relation
};
insert sobjectList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment