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
GeigerJHGeigerJH 

S2S Trigger Problem - Invalid_Partner_Network_Status

I am trying to implement a very simple auto sharing Salesforce to Salesforce trigger and it is throwing an error that makes no sense. I am developing this in the Sandbox and I have created a connection to another sandbox.

 

Invalid_Partner_Network_Status

 

I have been debugging things so that I know the ConnectionId, LocalRecordId, and ParentRecordId's are all accurate. The problem is that when it goes to insert the connection it throws the error above. 

 

Now according to the PartnerNetworkRecordConnection page below, this error is thrown when either the connecting org is not subscribing to the object that is being shared OR when you try to share a record that is already being shared. Neither of these can be the case as I am running the trigger as an 'AFTER INSERT' trigger so the opportunity is brand new. And I can manually share and accept the opportunity with the other sandbox org.

 

Why else could this error be thrown??? 

 

Please help!

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_partnernetworkrecordconnection.htm   

GeigerJHGeigerJH

Below is the code I am currently working with... I will make it more dynamic as soon as I can get it to work at all! 

 

 

trigger S2SAutoShareOpptyAfterInsert on Opportunity (after insert) {

 

id networkId = ConnectionHelper.getConnectionID('Sample CO.');

 

PartnerNetworkRecordConnection newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId ,
LocalRecordId = trigger.new[0].Id,
SendClosedTasks = false,
SendOpenTasks = false,
SendEmails = false,
ParentRecordId = trigger.new[0].AccountId);

 

system.debug('--------------- PARENTrecord Id is ...' + trigger.new[0].AccountId);
system.debug('--------------- RECORD Id is ...' + trigger.new[0].Id);
system.debug('--------------- CONNECTION Id is ...' + networkId);

 

insert newConnection;

}

Tomeka WrayTomeka Wray
Did you ever get your code to work? I am having the same issue.
Tomeka WrayTomeka Wray
After working with the Salesforce Support team, I found that the field that I was using in newConnection was not selected in the S2S mapping. After adding the missing field, it worked. So just insure that the fields that you are referencing in your code are also referenced on the Connection page.