Newer Version Available

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

Create a Sample DataSource.Provider Class

Now you need a class that extends and overrides a few methods in DataSource.Provider.

Your DataSource.Provider class informs Salesforce of the functional and authentication capabilities that are supported by or required to connect to the external system.

If the external system requires authentication, Salesforce can provide the authentication credentials from the external data source definition or users’ personal settings. For simplicity, however, this example declares that the external system doesn’t require authentication. To do so, it returns AuthenticationCapability.ANONYMOUS as the sole entry in the list of authentication capabilities.

This example also declares that the external system allows SOQL queries, SOSL queries, Salesforce searches, upserting data, and deleting data.
  • To allow SOQL, the example declares the DataSource.Capability.ROW_QUERY capability.
  • To allow SOSL and Salesforce searches, the example declares the DataSource.Capability.SEARCH capability.
  • To allow upserting external data, the example declares the DataSource.Capability.ROW_CREATE and DataSource.Capability.ROW_UPDATE capabilities.
  • To allow deleting external data, the example declares the DataSource.Capability.ROW_DELETE capability.

Lastly, the example identifies the SampleDataSourceConnection class that obtains the external system’s schema and handles the queries and searches of the external data.