Sub topic 3
Choosing an adapter
This chapter assumes you know what Salesforce Connect does and why it leaves data in place. It also assumes you have a basic idea of REST and OData. You do not need Apex yet. The Apex part only matters for the last option.
What an adapter does
A Salesforce Connect adapter is the piece of the platform that talks to the external system. When a user opens an external object record, the adapter turns the request into a call the external system understands. It then maps the response back into rows and fields.
You pick the adapter when you create the external data source. It cannot be swapped later without recreating the data source, and the external objects generated from it would need to be re-synced. So the choice deserves some thought up front.
The four options
| Adapter | Use it when | Needs from the external system |
|---|---|---|
| OData 2.0 | The system exposes an OData 2.0 producer | A service root URL and a metadata document |
| OData 4.0 | The system exposes an OData 4.0 producer | A service root URL and a metadata document |
| Cross-org | The data lives in another Salesforce org | A Salesforce org that you can authenticate to |
| Custom Apex | No standard adapter fits | Anything you can reach with Apex code |
OData 2.0 and OData 4.0
OData is a standard REST-based protocol for querying and updating data. If the external system already publishes an OData endpoint, one of these adapters is the lowest-effort choice. Salesforce reads the endpoint's metadata to learn the tables and columns, so you write no code.
Choose the version the endpoint actually serves. Many older enterprise gateways only speak OData 2.0. Newer services usually offer 4.0. If both are available, prefer 4.0.
Cross-org
The cross-org adapter connects to another Salesforce org through its REST API. The remote org's objects and fields become external objects in your org. It is the right choice when two orgs must share data without duplicating it, for example a parent company org and a subsidiary org.
Custom Apex adapter
If the system has no OData endpoint, you can write an adapter with the Apex Connector Framework. You can use it to call a plain REST or SOAP API, or to reshape data that an existing adapter cannot handle. This option costs the most to build and maintain, because you own the code, the tests, and the query handling. A later chapter covers how to build one.
A decision flow
Factors beyond the protocol
Matching the protocol is the first test. Check these points too before you commit:
- Authentication. The adapter must support the way the external system authenticates. Named credentials, covered in the next chapter, handle most cases.
- Write support. Reading is the default. Writing back needs the data source to allow it and the external system to accept it.
- Query features. The external system has to handle the filters, sorting, and paging that SOQL requests turn into. A weak endpoint makes every adapter slow.
- Reachability. Salesforce makes the calls, so the endpoint must be reachable from Salesforce over the network.
Exercise
Your company stores product data in a system that offers only a SOAP API, with no OData endpoint. Which adapter do you choose, and why?
Show answer
The custom Apex adapter, built with the Apex Connector Framework. The OData adapters need an OData endpoint, and the cross-org adapter only connects to Salesforce orgs. Apex code can call the SOAP API and return the rows.
Exercise
A partner exposes the same data through both an OData 2.0 and an OData 4.0 endpoint. Which adapter should you generally choose?
Show answer
The OData 4.0 adapter, because it is the newer version of the protocol. Use 2.0 only if the 4.0 endpoint is unavailable or lacks something you need.