Last active
October 19, 2020 12:48
-
-
Save ChristineSFB/4f3f6a7e2bf26782655b60954353df94 to your computer and use it in GitHub Desktop.
Introduction to Salesforce Connect for External Applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Introduction to Salesforce Connect for External Applications |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class ProviderClass extends DataSource.Provider { | |
override global List getAuthenticationCapabilities() { | |
List capabilities = new List(); | |
capabilities.add(DataSource.AuthenticationCapability.ANONYMOUS); | |
return capabilities; | |
} | |
override global List getCapabilities() { | |
List capabilities = new List(); | |
capabilities.add(DataSource.Capability.ROW_QUERY); | |
capabilities.add(DataSource.Capability.SEARCH); | |
//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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<DataSource.Table> sync(); | |
DataSource.TableResult query(DataSource.QueryContext c); | |
List<DataSource.TableResult> search(DataSource.SearchContext c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
columns.add(DataSource.Column.url('DisplayUrl')); | |
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tables.add(DataSource.Table.get('LoanAccountInfo', 'Name', loanAccColumns)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() + ‘/’); | |
rows.add(row); | |
return DataSource.TableResult.get(c,rows); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To find the table name | |
queryContext.tableSelection.tableselected | |
// To pull the column used in the filter condition | |
queryContext.tableSelection.filter.columnName | |
// to find the type of operation (EQUALS, GRETER THAN, LESS THAN or etc) | |
queryContext.tableSelection.filter.type | |
// To find the sub filters used with Not/OR/AND | |
queryContext.tableSelection.filter.subfilter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment