Introduction to Salesforce Connect for External Applications

By Sravanthi Aitha

Jim is the sales manager of a large real-estate giant, based in Brooklyn. The company has recently implemented Salesforce and uses data from 8 external sources to power the CRM system. The members of Jim’s team need to switch from Salesforce to the external sources and back several times a day. This involves much effort from the user and productivity is taking a big hit.

Jim and his users are not alone in facing this sort of issue; many Salesforce users have a horrid time moving between Salesforce and external applications. So, how can this problem be resolved? Salesforce Connect offers the solution, providing integration that allows users to view and manage external data from within the Salesforce application, eliminating the need to switch between systems. In this post, we’ll learn what Salesforce Connect is and how you can set it up.

What Is Salesforce Connect?

Salesforce Connect is a powerful App Cloud integration service, which enables users of Salesforce applications to seamlessly access and handle data stored in external sources, without leaving the Salesforce native environment.

You can use Salesforce Connect to fetch data from on-premise applications, as well as cloud-based sources. You can allow all users of your Salesforce org to connect with an external data source using only one login account or create a separate login account for each user.

How Can You Link Salesforce Connect with External Applications?

You can use the following data adapters to establish a connection between an external data source and Salesforce Connect:

  1. Open Data Protocol (OData): OData is a very popular REST-based protocol, used extensively for integrating data. You can link data sources, exposed by OData 2.0 or 4.0 producers, to Salesforce Connect.
  2. Custom-developed adapters: You can also create easy-to-use adapters in Apex, which enable you to link APIs that are not in the OData format. These tailor-made adapters allow you to connect to any web API. You can also use the adapters to link to thousands of publicly available APIs.
  3. Salesforce Connector: This adapter is ideally suited if you use multiple Salesforce instances. Salesforce Connector is a very user-friendly adapter and can be used to connect external applications without any coding.

Steps to Set Up Salesforce Connect

  1. Create a new external data source: If the external data source has more than one service, you will need to create a data source for each service. You can create a data source by completing the fields shown in the image below and clicking Save and New.
  2. Create the external object and fields: Once you create the external data source, you need to click the Validate and Sync button (highlighted in the image below), to fetch the list of tables in the data source.

Then, select the tables you wish to synchronize with Salesforce and click the button Sync (highlighted below) to access the external objects just like the custom objects in your Salesforce instance.

Create relationships between data objects in the external source and your Salesforce instance: You can establish 3 types of relationships between the external data objects and their counterparts in your Salesforce data system: Lookup, External Lookup and Internal Lookup. The image below lists the possible parent-child data object relationships:

Once you link the data objects in the external source with those in your Salesforce instance, you are ready to access and use the external data within your native environment.

Next, we’ll review how we can develop custom adapters in Apex to access external data, using Lightning Connect.

Creating Custom Adapters for Lightning Connect

You can develop custom adapters for Lightning Connect using two widely-used abstract classes: DataSource.Provider and DataSource.DataSourceConnection.

DataSource.DataSourceConnection enables users to access and handle the data in an external source, whereas DataSource.Provider helps establish a link with the external source.

Using DataSource.Provider to set up a connection with the external data source

Before we learn how we can use DataSource.Provider, it is important to know the Provider class is prefixed by Custom- and is indicated as Lightning Connect: Custom-Adapter Connection under the field Type.

You need to write the following piece of code to create a custom adapter:
[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]

When you create an adapter from Setup, a new Type option is displayed, which indicates your Apex Provider class, along with the standard Lightning Connect adapters provided by Salesforce.

We’ll now explore various methods used to connect with, and fetch data from, external sources.


The types of authentication supported are:

  • ANONYMOUS (no authentication)
  • BASIC (for basic authentication)

The object DataSource.AuthenticationCapability provides the enums for these authentications.


The object DataSource.Capabilities provides different enums that help execute Create, Read, Update and Delete (CRUD) operations on external objects.


This method gets called during the execution of SOQL / SOSL queries. The connection parameters will be based on the admin configurations in the External Data Source page in Setup. For more information, check out Capability Enum on the Salesforce Developers website.


DataSourceConnection abstract class contains three methods, indicated in the image below:
[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]


This method is called when you click the Validate and Sync button on the External Data Source page in Setup. The tables and columns you define in this method will be created in your Salesforce as external tables and the table schema will be returned as a DataSource.Table object. You can create multiple external tables using a single data source. Each data table defines a set of columns using a DataSource.Columns object.
[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]

You can accommodate definitions of multiple tables using the sync method, as indicated in the image below:
[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]

The LoanAccColumns accommodate the second table’s column information. When the data source is validated, you can see the two tables: LoadInfo and LoanAccountInfo. Then, you can sync these two external tables to have them and their columns created in Salesforce.


When you navigate through the data in a related list, a list view or the search bar, the system executes an SOQL query, which in turn calls this query method to fetch the data. This method returns the data in the form of a DataSource.TableResult object; however it will not handle the count, offset or limit.

[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]

Two objects can be used for setting up or reading the filters in SOQL: DataSource.Filter and DataSource.FilterType. These filters must be used with respect to the QueryContext object class.

[gist id=”4f3f6a7e2bf26782655b60954353df94″ file=””]


The search method is executed when you run a SOSL query or use the global search in Salesforce.


Salesforce Connect is a very useful integration service that allows users in the native Salesforce environment to access and handle data from external sources in a hassle-free manner. Using the steps and the methods discussed above, you can supercharge your user’s productivity by removing the need to switch between multiple systems.


For more information check out the following resources:

Salesforce Connect: Delivering Connected Apps for Customer Success

Introducing Lightning Connect Custom Adapters

The Author

Sravanthi Aitha

I'm a Salesforce technical architect with 7+ years of experience and hold PD2, PD1, App Builder, SCJP certifications.


    January 15, 2021 10:43 am
    Very innovative and inspiring
    June 28, 2021 8:33 am
    Spot on instructions. Useful.
    June 30, 2021 10:53 am
    Sravanthi, thanks a lot for your informative article! What do you think about third-party apps like Skyvia ( I found it very easy and convenient to use.
    August 15, 2021 2:05 am
    Has anyone experienced using this to sync SF with another CRM e.g. dynamics?
    March 29, 2022 5:45 pm
    Is it possible to view an image from an enterprise document store (e.g. FileNet, Datastore DSX) in Salesforce?

Leave a Reply