The requirement is to inserting parent record and and creating association with child while in Child Insert trigger.
Based on this link : https://sfcure.com/2017/11/20/inserting-updating-parent-and-child-records-in-a-single-transcation-using-external-id-field/
- after insert on child, insert parent record with external id
- update child association based on external id of parent
However receiving error "Illegal assignment from Individual_Email_Summary__c to Id" .
Below is clip of it on after insert of child record. It is written in forloop for bulkification .Below clip is from anonymous window for just one record. Individual_Email_Summary__c : Parent et4ae5__IndividualEmailResult__c : Child
List<Individual_Email_Summary__c> AggrToinsert = new List<Individual_Email_Summary__c>();
List<et4ae5__IndividualEmailResult__c> AggrToUpdate = new List<et4ae5__IndividualEmailResult__c>();
AggrToinsert.add(new Individual_Email_Summary__c(
Contact__c = '0030m00000UZ6RF',
Updated_Month__c = system.today(),
MyExtId__c = '0030m00000UZ6RF_Ex'
));
AggrToUpdate.add(new et4ae5__IndividualEmailResult__c(
id = 'a370m000000QWKY',
Individual_Email_Summary__c = new Individual_Email_Summary__c(
MyExtId__c='0030m00000UZ6RF_Ex'
)
));
// Currently failing here with "Illegal assignment from Individual_Email_Summary__c to Id"
Database.SaveResult[] srInsertList = Database.insert (AggrToinsert, false);
Database.SaveResult[] srupdateList = Database.update(AggrToUpdate);
Any thoughts on resolving this issue will be appreciated