Newer Version Available

This content describes an older version of this product. View Latest

Connection Class

Extend this class to enable your Salesforce org to sync the external system’s schema and to handle queries, searches, and write operations (upsert and delete) of the external data. This class extends the DataSourceUtil class and inherits its methods.

Namespace

DataSource

Usage

Your DataSource.Connection and DataSource.Provider classes compose a custom adapter for Salesforce Connect.

Changing the sync method on the DataSource.Connection class doesn’t automatically resync any external objects.

Example

Connection Methods

The following are methods for Connection.

deleteRows(deleteContext)

Invoked when external object records are deleted via the Salesforce user interface, APIs, or Apex.

Signature

public List<DataSource.DeleteResult> deleteRows(DataSource.DeleteContext deleteContext)

Parameters

deleteContext
Type: DataSource.DeleteContext
Contains context information about the delete request.

Return Value

Type: List<DataSource.DeleteResult>

The results of the delete operation.

query(queryContext)

Invoked by a SOQL query of an external object. A SOQL query is generated and executed when a user visits an external object’s list view or record detail page in Salesforce. Returns the results of the query.

Signature

public DataSource.TableResult query(DataSource.QueryContext queryContext)

Parameters

queryContext
Type: DataSource.QueryContext
Represents the query to run against a data table.

Return Value

Type: DataSource.TableResult

sync()

Invoked when an administrator clicks Validate and Sync on the external data source detail page. Returns a list of tables that describe the external system’s schema.

Signature

public List<DataSource.Table> sync()

Return Value

Type: List<DataSource.Table>

Each returned table can be used to create an external object in Salesforce. On the Validate External Data Source page, the administrator views the list of returned tables and selects which tables to sync. When the administrator clicks Sync, an external object is created for each selected table. Each column within the selected tables also becomes a field in the external object.

upsertRows(upsertContext)

Invoked when external object records are created or updated via the Salesforce user interface, APIs, or Apex.

Signature

public List<DataSource.UpsertResult> upsertRows(DataSource.UpsertContext upsertContext)

Parameters

upsertContext
Type: DataSource.UpsertContext
Contains context information about the upsert request.

Return Value

Type: List<DataSource.UpsertResult>

The results of the upsert operation.