Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Introduction to Salesforce Connect for External Applications
Introduction to Salesforce Connect for External Applications
global class ProviderClass extends DataSource.Provider {
override global List getAuthenticationCapabilities() {
List capabilities = new List();
return capabilities;
override global List getCapabilities() {
List capabilities = new List();
//ROW_CREATE - Allows the users to create records
//ROW_UPATE - Allows the users to update the records
return capabilities;
override global DataSource.Connection getConnection(DataSource.ConnectionParams connectionParams) {
return new DataSourceConnectionClass();
List<DataSource.Table> sync();
DataSource.TableResult query(DataSource.QueryContext c);
List<DataSource.TableResult> search(DataSource.SearchContext c);
global class DataSourceConnectionClass extends DataSource.Connection {
global DataSourceConnectionClass(DataSource.ConnectionParams connectionParams) {
global DataSourceConnectionClass() {}
override global List sync() {
List tables = new List();
List columns;
columns = new List();
// Always declare these two fields.
columns.add(DataSource.Column.text('ExternalId', 255));
// These are custom fields for our external object.
// objects that are created when synced from this adapter.
columns.add(DataSource.Column.text('CustomerName', 255));
columns.add(DataSource.Column.number('LoanId', 18, 0));
tables.add(DataSource.Table.get('LoanInfo', 'Name', columns));
return tables;
tables.add(DataSource.Table.get('LoanAccountInfo', 'Name', loanAccColumns));
override global DataSource.TableResult query(DataSource.QueryContext c) {
List<Map<String,Object>> rows = new List<Map<String,Object>>();
Map<String,Object> row = new Map<String,Object>();
row.put('CustomerName', ‘Test Customer’);
row.put('LoanId', 128364232);
row.put('ExternalId', ‘343532’);
row.put('DisplayUrl', URL.getSalesforceBaseUrl().toExternalForm() + ‘/’);
return DataSource.TableResult.get(c,rows);
//To find the table name
// To pull the column used in the filter condition
// to find the type of operation (EQUALS, GRETER THAN, LESS THAN or etc)
// To find the sub filters used with Not/OR/AND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment