How to insert child record using Parent record's External Id field?

Sample Code:

Hobby__c h = new Hobby__c(Name = 'Test');
h.Employee__r = new Employee__c(Employee_Primary_Email__c = '');
insert h;

here Employee__c is the field which is a lookup to Employee__c object and Employee_Primary_Email__c is the External Id field.


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit