Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Filters in the Apex Connector Framework
For example, when a user goes to an external object’s record detail page, your DataSource.Connection is executed. Behind the scenes, we generate a SOQL query similar to the following.
1SELECT columnNames
2FROM externalObjectApiName
3WHERE ExternalId = 'selectedExternalObjectExternalId'This SOQL query causes the query method on your DataSource.Connection class to be invoked. The following code can detect this condition.
1if (context.tableSelection.filter != null) {
2 if (context.tableSelection.filter.type == DataSource.FilterType.EQUALS
3 && 'ExternalId' == context.tableSelection.filter.columnName
4 && context.tableSelection.filter.columnValue instanceOf String) {
5 String selection = (String)context.tableSelection.filter.columnValue;
6 return DataSource.TableResult.get(true, null,
7 tableSelection.tableSelected, findSingleResult(selection));
8 }
9}This code example assumes that you implemented a findSingleResult method that returns a single record, given the selected ExternalId. Make sure that your code obtains the record that matches the requested ExternalId.