Change Data Capture using external sources and external object

Two Salesforce environments are connected by an authentication provider. Let us take two salesforce environments as source and destination. By using this if we change any record in source org it will dynamically change it to the destination org.

Solution Description

  • Create a Connected App in Source org.
  • That connected app will be used in Destination org by creating an authentication provider.
  • Create an external data source in Destination to get data from source to destination.
  • After creating an external data source, we have to use an external object in that.

First, we want to create the Auth provider with a sample consumer key and Consumer Secret for getting the callback URL to set into the Connected App. After creating Auth provider only, we can get call back URL (this call back URL will be saved into the Connected App).

After creating the Connected app only, the Consumer key and Consumer Secret will be saved into the Auth Provider (After getting Consumer Key and Consumer Secret from the Source org then go to edit the Auth provider in destination org, and then we will paste the Consumer Key and Consumer secret into the Auth provider)

Create a Connected App in Source org

In the source environment, go to setup and search App Manager and then click on the newly connected app and give the details as follows.

Connected App Name: [name of your choice]

Contact Email: [your email]

Web App Settings

Then click save now you get the Consumer key and Consumer secret for the Auth Provider

Create Auth Provider in Destination Org

Select Salesforce on appearing the drop-down list

Give the sample data in the Consumer key and Consumer secret for getting callback URLs to click on save now you get the callback URL and copy.

Get Callback URL

After copying the callback URL Paste it into the Source org connected App. Then we can get the Consumer key and Consumer Secret from the connected App now go to the destination org and edit the Auth provider and replace the actual Consumer key and the consumer secret we get from the source org connected app.

Create an external data source in the destination to get data from the source environment to the target environment.

Create External Data Source in Salesforce
Connect to the Auth provider

After entering, and saving the external data source will authenticate the Org. The first time it will redirect to login. Authenticate it with the target org credentials.

Allow access for the Auth Provider
Validate and Sync External Data Sources in Salesforce

From the example, I have selected only the account object and synced it

Rename the external object by editing it. Create Custom Tab if needed.

Now edit the data in the source environment that will be updated in the target environment too.

Considerations to use External Objects

  • Maximum external objects per org are 200
  • Naming Conventions of External Object
    • Object name must be unique across all standard, custom, and external objects in the org
    • In the API, the names of external objects are identified by a suffix of two underscores immediately followed by a lowercase “x” character. For example, an external object named “ExternalLogInfo” in the Salesforce user interface is seen as ExternalLogInfo__x

Leave A Comment

All fields marked with an asterisk (*) are required