How to Connect Two Salesforce Orgs: A Comprehensive Guide

Organizations often operate multiple Salesforce orgs to address diverse operational needs, handle specific business units, or collaborate with external partners. Sharing records or data between these Salesforce orgs becomes crucial in such cases. Salesforce provides several robust ways to achieve this, ensuring seamless data exchange. This article explores three popular methods for connecting two Salesforce orgs: Salesforce-to-Salesforce Connection, Integration using Flows, and Integration using REST API.

1. Salesforce-to-Salesforce Connection

Key Features:

  • Share standard and custom objects.
  • Bi-directional synchronization of records.
  • Granular control over data sharing using record-level permissions.

Use Cases:

  • Partner collaborations (e.g., resellers accessing product inventory or opportunities).
  • Sharing data between multiple orgs within the same organization.

Setup Process:

  1. Enable Salesforce-to-Salesforce:
  • Go to Setup > Salesforce to Salesforce Settings > Enable the feature.
  1. Establish Connection:
  • Exchange connection invitations between the two orgs (via email).
  • Accept and activate the connection in both orgs.
  1. Publish and Subscribe Objects
  • Define the objects and fields to share by publishing them in one org and subscribing in the other.
  1. Share Records
  • Manually share records or automate sharing using workflows or processes.

2. Integration Using REST API

We can integrate by writing the code. Additionally, flows can also be used to make callouts. We can create custom web services using Apex or utilize the stand APIs present in Salesforce. The basic flow will authorize the request and then use a token to create data in Salesforce.

Steps to Integrate :

  1. Create a Connected App in both instances ie the Target Org and source org:
    1. Navigate to Setup → App Manager in the Target Org.
    2. Click New Connected App, provide the app’s name, and enable OAuth settings.
    3. Note the Consumer Key and Consumer Secret for authentication.
  2. Configure Remote Site Settings in both instances Source Org:
    1. Go to Setup → Remote Site Settings and add the Target Org’s URL (e.g., https://<target-org>.my.salesforce.com)
  3. Creating a web service or using standard APIs

For more complex use cases, integrating via REST API using Apex provides greater flexibility and control. This method requires coding but offers robust error handling, customization, and scalability.

Develop a class to expose a REST API endpoint that handles incoming data and performs the required operations, such as creating a record.

Develop a trigger on the object you want to synchronize (e.g., Account) to initiate the integration process upon record creation or update.

If one wants two-way communication then the trigger and web service will be created in both instances

Testing and Monitoring:

  1. Test the integration by creating sample records in the Source Org and verifying their creation in the Target Org.
  2. Monitor API usage to ensure limits are not exceeded.

Security Notes:

  • Avoid hardcoding sensitive information like passwords; consider using Named Credentials or encrypted fields.
  • Incorporate comprehensive error management and monitoring mechanisms to maintain reliable integrations.

Conclusion

Connecting multiple Salesforce orgs can streamline business operations and foster collaboration. Choosing the right method—Salesforce-to-Salesforce Connection, Flows, or REST API—depends on your use case, complexity, and security requirements. With careful planning and execution, you can ensure seamless data exchange between Salesforce orgs, enhancing productivity and operational efficiency.

Scroll to Top