function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
stripathystripathy 

S2S - Error INVALID_PARTNER_NETWORK_STATUS

I am trying to auto sync a child record which is a child of account. I am getting this error, though the account is getting synced properly. I have written a trigger on the child object. Code given below. Any suggestions how to fix this?

 

trigger AdressS2s on Address_vod__c (after insert, after update) {


// Define connection id
Id networkId = ConnectionHelper.getConnectionId('sss');

Set<Id> localAddressAccountSet = new Set<Id>();
List<Address_vod__c> localAddress_vod_cs = new List<Address_vod__c>();
Set<Id> sharedAccountSet = new Set<Id>();

// only share records created in this org, do not add contacts received from another org.

for (Address_vod__c newAddress_vod_c: TRIGGER.new) {

localAddress_vod_cs.add(newAddress_vod_c);

}



System.debug('Inside address trigger -->');
//if (sharedAccountSet.size() > 0) {
List<PartnerNetworkRecordConnection> Address_vod_cConnections = new List<PartnerNetworkRecordConnection>();

for (Address_vod__c newAddress_vod_c: localAddress_vod_cs) {

// if (sharedAccountSet.contains(newAddress_vod_c.Account_vod__c)) {

System.debug('Inside address trigger final loop -->'+ newAddress_vod_c);

PartnerNetworkRecordConnection newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newAddress_vod_c.Id,
SendClosedTasks = false,
SendOpenTasks = false,
SendEmails = false,
ParentRecordId = newAddress_vod_c.Account_vod__c);

Address_vod_cConnections.add(newConnection);

//}
}

if (Address_vod_cConnections.size() > 0 ) {
System.debug('Size greater than 0 -->'+ Address_vod_cConnections);
try{
database.insert(Address_vod_cConnections);
}
Catch(exception ex){
System.debug('exception in sending'+ex.getmessage());
}

}

}


//}

Anup JadhavAnup Jadhav

Your question is incomplete. What are you auto-syncing in your child record? What is the nature of this "sync"? Also, what error message do you get? Can you highlight the line which throws the error message?

 

Anup

stripathystripathy

The error message comes on the line  database.insert operation. Nature of sync is push i..e the trigger code is written on the source org and on the target org it has been auto subscribed to a few fields to the source. 

 

EXCEPTION_THROWN|[48]|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_PARTNER_NETWORK_STATUS, invalid status for partner network operation: []