Last active
April 6, 2020 16:54
-
-
Save mhamzas/64bbccc25a41f68509e83781ee8baa0e to your computer and use it in GitHub Desktop.
Insert Records in multiple Objects in single DML | https://www.mhamzas.com/blog/2020/04/06/insert-records-in-multiple-objects-in-single-dml/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<sObject> records = new List<sObject>(); | |
| records.add(new Account(AccountExternalId__c='1234555', Name='ABCD Company')); | |
| records.add(new Contact(account=new Account(AccountExternalId__c='1234555'),lastname = 'Testlast', ContactExternalId__c='3525')); | |
| records.add(new AccountContact__c (Contact__r = new Contact(ContactExternalId__c='3525'))); | |
| insert records; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment