I'm trying to insert contact and account records in a single DML.
In my case I don't want to use the .
operator Instead, I'm using the put
operator to insert records.
Account acc=new Account(Name='Test Acc 8', External_Id__c='ext123');
Account a = new Account(External_Id__c='ext123');
Contact con = new Contact();
con.put('LastName', 'kk');
con.put('Account',a);
Above code results in error:
System.SObjectException: Invalid field Account for Contact
Although when I use:
Account acc=new Account(Name='Test Acc 8', External_Id__c='ext123');
Account a = new Account(External_Id__c='ext123');
Contact con = new Contact();
con.LastName = 'kk';
con.Account = a;
it works.
PS: External_Id__c
is an external id field on Account.