4

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.

2
  • I got it to work. I don't see anything wrong with the code. Are you able to manually push records from one org to another? Does updating a record, automatically update the shared record in the other org? Also, have you set up emails to go out as part of the S2S integration. – venky Apr 3 '15 at 1:28
  • @venky see my answer to the question. – Acuariano Apr 14 '15 at 20:49
4

Here status invite means the record you have just shared is not created in organization and require other organization owner to accept the record. When you create record by this, an invitation email is sent to connection owner with a link to records you are inserting/updating to organization. On that link connection owner accept or decline the record creation. Until the connection owner doesn't accept the change, the record will not insert in target organization.

2

The problem in this case was that the target org didn't have enough space to create the records. Freeing up space in the target org solved the problem.

2
  • What about if it is a fresh org – Shantanu Mahajan Feb 2 '16 at 8:24
  • 1
    I assume you would have enough space in a fresh org. – Acuariano Feb 10 '16 at 2:13
1

Make sure the connection to the other org is active. Once is active make sure the target object is set to "Automatically Accept Records", otherwise, you will have to wait for someone to actually accept the record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.