title: Insert to Parent and child custom object using external Id
body: <p>I am trying to insert a record into a child custom object using the external id of the parent custom object. I am almost clear on how to setup the external id field in the parent object, but very confused with how to setup a foreign key in my child object. I am attaching the pics here which has details of the master and child custom objects. What I am i supposed to add to the child custom object to link its records to the parent object.</p>
  
  <p>Also here is the code I got from another post in stackoverflow, but that didn't work in my case</p>
  
  <pre><code>enter image description heresumchans__City_Master__c city = new sumchans__City_Master__c(Name='[![enter image description here][1]][1]Vancouver',sumchans__PROVINCE__c = 'BC', sumchans__City_Name_Ext_Id__c = 'Vancouver');
  insert city;
  sumchans__City_Stat__c cityStat = new sumchans__City_Stat__c(Name = 'Vancouver', sumchans__ON_BILLINGS__c = 50, sumchans__City_Master__c=new sumchans__City_Master__c(sumchans__City_Name_Ext_Id__c='Vancouver'));
  insert cityStat;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/59aRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/59aRS.png" alt="enter image description here"></a></p>