title: Reference Parent Object in Apex
body: <p>I have a custom object set up within Salesforce called Solar_Install. I have a S2S connection with another installation of Salesforce. I want to share the custom object with them as well as the parent object (Account), partly because child objects inherit the autoshare property from their parent so I have to.</p>
  
  <p>I have an Apex trigger on the child object (the Solar_Install) which looks like this:</p>
  
  <pre><code>trigger shareWithPartner on Solar_Install__c (after insert) {
  
  PartnerNetworkRecordConnection newConnection =
                  new PartnerNetworkRecordConnection(
                      ConnectionId = '12AB3456789CDEF',
                      LocalRecordId = trigger.new[0].id,
                      SendClosedTasks = false,
                      SendOpenTasks = false,
                      SendEmails = false,
                      ParentRecordId = ???);
  insert newConnection;
  }
  </code></pre>
  
  <p>but I don't know what to put in for the ??? value. I have tried various things:</p>
  
  <p>trigger.new[0].Account_c.AccountId</p>
  
  <p>Error: Compile Error: Invalid foreign key relationship: Solar_Install__c.Account_c at line 10 column 57</p>
  
  <p>Account_c</p>
  
  <p>Error: Compile Error: Variable does not exist: Account_c at line 10 column 42</p>
  
  <p>etc. Does anyone know how I reference the parent (Account) Id from this custom object in order that I can specify it as the ParentRecordId?</p>
  
  <p>Cheers</p>