• Ravi-SFDC
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Requirement :- I have two objects Nomination__c and Participant__c. Hight level these object are related to Training.

Participants get nominated for Trainings. Nomination has capture all details of Participants so that if participants does not exist then it create new participants. abc_Email_ID__c is the field which we use to check if participant exist or not. "abc_Email_ID__c" is external id in Nomination and Participant__c.

 

I want ot use cascade inset functionality in Berfore Insert trigger on Nomination.Idea is insert Participant__c and associate atutomatically with Nomination when Nomination record is inserted.

Below is the sample code i am trying to run through Anonymous block when i am running it gives me following error

 

|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, Foreign key external ID: testing119@abc.com not found for field abc_Email_ID__c in entity Participant__c: []

 

Any idea why i am getting this error

 

code :-

 

Nomination__c nomiObj = new Nomination__c();
nomiObj.Employee_Name__c='testing119';
nomiObj.abc_Email_ID__c='testing119@abc.com';
nomiObj.Training_Name__c='a01Z000000O8EeS';
Participant__c partObj = new Participant__c();
            
            partObj.abc_Email_ID__c=nomiObj.abc_Email_ID__c;
             
             nomiObj.EmployeeID__r=partObj;
insert nomiObj;

Requirement :- I have two objects Nomination__c and Participant__c. Hight level these object are related to Training.

Participants get nominated for Trainings. Nomination has capture all details of Participants so that if participants does not exist then it create new participants. abc_Email_ID__c is the field which we use to check if participant exist or not. "abc_Email_ID__c" is external id in Nomination and Participant__c.

 

I want ot use cascade inset functionality in Berfore Insert trigger on Nomination.Idea is insert Participant__c and associate atutomatically with Nomination when Nomination record is inserted.

Below is the sample code i am trying to run through Anonymous block when i am running it gives me following error

 

|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, Foreign key external ID: testing119@abc.com not found for field abc_Email_ID__c in entity Participant__c: []

 

Any idea why i am getting this error

 

code :-

 

Nomination__c nomiObj = new Nomination__c();
nomiObj.Employee_Name__c='testing119';
nomiObj.abc_Email_ID__c='testing119@abc.com';
nomiObj.Training_Name__c='a01Z000000O8EeS';
Participant__c partObj = new Participant__c();
            
            partObj.abc_Email_ID__c=nomiObj.abc_Email_ID__c;
             
             nomiObj.EmployeeID__r=partObj;
insert nomiObj;