I'm trying to share with a Connection new Accounts. I used the trigger examples to create the following trigger:
trigger SendAccountsToConnection on Account (after insert) {
PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and ConnectionName = 'Connection Name'];
List<PartnerNetworkRecordConnection> recordConnectionToInsert = new List<PartnerNetworkRecordConnection> ();
for (Account acc : Trigger.new){
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = conn.Id;
newrecord.LocalRecordId = acc.id;
newrecord.SendClosedTasks = false;
newrecord.SendOpenTasks = false;
newrecord.SendEmails = false;
recordConnectionToInsert.add(newrecord);
}
if (recordConnectionToInsert.size() > 0){
System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
insert recordConnectionToInsert;
}
}
Based on the debug log, the record is inserted. But when I look for it, it show with "Status"="Invite", which I can't find in the documentation (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_partnernetworkrecordconnection.htm) and the Account doesn't show in target org.