Sub topic 5
Creating an external data source
An external data source is the Setup record that tells Salesforce where an external system lives, which adapter to use, and how to authenticate. Every external object belongs to exactly one external data source. This chapter walks through creating one.
This chapter assumes you know the Salesforce data model, can navigate Setup, and have a named credential for the external system (covered in the previous chapter). You also need the adapter type you chose earlier. Basic OData concepts help.
What the data source holds
The external data source stores the connection settings. It does not store any external data. The main settings are:
| Field | Purpose |
|---|---|
| Label and Name | Display name and API name. The name is used when you generate external objects. |
| Type | The adapter: Salesforce Connect OData 2.0, OData 4.0, Cross-Org, or a custom Apex adapter. |
| URL | The service root of the external system. With a named credential, the URL comes from the credential instead. |
| Identity Type | Whether all users share one set of credentials (Named Principal) or each user authenticates separately (Per User). |
| Authentication Protocol | Anonymous, Password, or OAuth 2.0. Not applicable when you use a named credential. |
| Writable External Objects | Allows create, update, and delete from Salesforce. Off by default. |
Create the data source
- From Setup, enter External Data Sources in Quick Find and select it.
- Click New External Data Source.
- Enter a Label. The Name fills in automatically. Keep it short, because it appears in generated names.
- Choose the Type, for example Salesforce Connect: OData 4.0.
- For URL, select your named credential if the field offers one. Otherwise enter the service root URL.
- Choose the Identity Type. Use Named Principal when one integration user can see all the data. Use Per User when the external system must enforce each person's own access.
- Set options such as Server Driven Pagination and High Data Volume, only if the service supports them.
- Click Save.
Settings that cause trouble
- Format. For OData sources, choose the format the service supports (Atom or JSON). A wrong choice causes parse errors at sync time.
- Server Driven Pagination. If the service pages its own results, enable this. Otherwise Salesforce asks for pages using client-driven paging, which some services do not support.
- Request timeout. The default is a few seconds. Raise it only if the service is slow, since users wait for each call.
- Writable External Objects. Leave it off unless you need writes. Turning it on has no effect if the external system rejects writes.
- Per User identity. Each user must then enter credentials under their own settings. Without this, they see authentication errors.
Check the result
After saving, open the data source detail page. It should show the type, the URL, and the identity type you chose. If the page shows a Validate and Sync button, the connection settings were accepted structurally. The button tests the connection, and the next chapter covers it.
A common error at this point is "The server returned an error" when you validate. Check three things in order:
- The named credential URL points at the service root, not at a single entity.
- The credential's authentication works. Test it from the named credential itself.
- Your remote site or network settings allow the call.
Exercise
Your team needs each salesperson to see only the external records they are permitted to see in the external system. Which Identity Type should the data source use, and what must each user do?
Show answer
Use Per User. Each user must authenticate to the external system with their own credentials, which they enter in their personal settings. The external system then enforces its own access rules for each person.
Exercise
A colleague changes the data source URL to a new service. The existing external objects now fail. Why, and what is the fix?
Show answer
The external objects still hold the schema from the original sync, which may not match the new service. Run Validate and Sync again so the objects reflect the new schema.