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.
I have an Apex trigger on the child object (the Solar_Install) which looks like this:
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;
}
but I don't know what to put in for the ??? value. I have tried various things:
trigger.new[0].Account_c.AccountId
Error: Compile Error: Invalid foreign key relationship: Solar_Install__c.Account_c at line 10 column 57
Account_c
Error: Compile Error: Variable does not exist: Account_c at line 10 column 42
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?
Cheers
Did you try traversing the Account relationship with Account_r.Id or Account_c (with two underscores)? These should be the same, but the latter would preferred because it doesn't require a join.