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
David KleinjanDavid Kleinjan 

Salesforce 2 Salesforce programatic sharing, status "Invite"/"Pending (sent)"

Hello,

I'm trying to share an Opportunity from Org1 Sandbox to Org2 Sandbox. Connection is configured on both sides with auto-accept enabled, Opportunity StageName, Name, CloseDate the only fields published/subscribed to.

This works fine when done manually; "forward this opportunity" (status "Active (sent)"/PNRC.Status=Sent ), however it fails when sharing programatically (via a Trigger on Opportunity insert), status is "Pending (sent)"/PNRC.Status=Invite.
Notes:
- No Invite emails to notify me of an incoming Opportunity share.
- There are no validation rules on the target org that would cause it to fail, as proven by the manual sharing working.
- No errors or useful information in the logs.
- Programatic sharing of a custom object works OK. 

Can anyone suggest a next step for diagnosing and resolving this problem? Let me know if you need any more information.

thanks,
David.
David KleinjanDavid Kleinjan
Some updates based on further testing:
  • The Opportunity now appears in the target Org, but is not auto-accepted. When accepting it, the is no Account associated, this has to be done manually
  • The manually shared Opportunity does not have a link to the parent Account 
crop1645crop1645
David -- Another possible cause is the following: If you have multiple lookups to Account within the Opportunity SObject, then auto-accept will never work without resorting to some clever coding on the target SFDC org. This is covered in detail here (http://cropredysfdc.com/2014/11/17/s2s-salesforce-to-salesforce-adventures/). The sending org's status will be Pending (sent).