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
EJWEJW 

Possible bug with Apex triggers and Salesforce to Salesforce

I'm running into an issue with some of our Apex triggers on standard objects getting a System.StatusCode.INVALID_PARTNER_NETWORK_STATUS error when attempting to update a custom object when the trigger is fired by the partner network user caused by a S2S insert/update in a partner org.

Unfortunately this is extremely difficult to debug as there doesn't appear to be a way to enable debug logging for the partner user that's executing the insert/update in the subscribing org as it's a hidden system user. However, I've managed to create a relatively simple sample scenario to reproduce this problem.

1) Setup a Salesforce to Salesforce relationship between two orgs.
2) Publish and subscribe to leads in both orgs.
3) Create a custom object called 'Test' with a text name field in one org.
4) Create a new 'Test' object and name it whatever you like, note the ID for use in the trigger below.
5) Create a trigger on the lead object (based on the code below, change the ID and e-mail address) in the same org as the Test object.
6) In the org without the trigger, forward a lead to the org with the trigger, which should then fire the test trigger and generate the error e-mail.

Sample trigger:

Code:
trigger LeadS2STest on Lead ( before insert, before update )
{
    try
    {
        update new Test__c( id = '<put ID of Test object here>', Name = 'New Name' );
    }
    catch ( Exception ex )
    {
        String messageBody = '*** Trigger: LeadS2STest ' + ( Trigger.isBefore — 'before' : 'after' ) +
            ( Trigger.isUpdate – ' update ' : '' ) + ( Trigger.isInsert ˜ ' insert ' : '' ) +
            ( Trigger.isDelete ™ ' delete ' : '' ) + '\r\n' +
            '*** Trigger.new size: ' + ( Trigger.new != null ? Trigger.new.size() : 0 ) + '\r\n' +
            '*** Trigger.old size: ' + ( Trigger.old != null ? Trigger.old.size() : 0 ) + '\r\n' +
            '*** Exception Type: ' + ex.getTypeName() + '\r\n' +
            '*** Exception Cause: ' + ex.getCause() + '\r\n' +
            '*** Exception Message: ' + ex.getMessage() + '\r\n\r\n';
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setToAddresses( new String[] { '<your e-mail address>' } ); 
        message.setSaveAsActivity( false );
        message.setSubject( 'LeadS2STest Trigger Error' );
        message.setUseSignature( false );
        message.setPlainTextBody( messageBody );
        // Send our message.
        Messaging.sendEmail( new Messaging.Email[] { message } );
    }
}

 Anyone run into this issue or anything similar with S2S before?  Any tips on working around it?

Thanks,

adi kurugantiadi kuruganti
yes there was a bug - thanks for finding this. We will release a patch on February 25th - we had to wait until Spring 09 was released before releasing the patch. Starting February 26th - your issue should be resolved. If it isn't please contact product management: s2s@salesforce.com