Sub topic 3
Showing External Data in Tabs, Layouts, and List Views
Assume you know Salesforce objects, permission sets, basic SOQL, and basic Apex. External objects let Salesforce display records that remain in another system.
Expose and relate external records
After Validate and Sync creates an external object, grant users object and field permissions through a permission set. Create a custom tab for the object, then configure its page layout and list views. These settings control which fields users see and how they filter or sort records.
An external lookup relates an external object to a Salesforce record through a supported relationship. An indirect lookup matches an external record to a Salesforce record using an external ID value. The external system remains the source of the external record.
flowchart TD
A[External object] --> B[Permission set]
B --> C[Custom tab]
B --> D[Page layout]
B --> E[List view]
A --> F[External or indirect lookup]
F --> G[Salesforce record]Query and write external data
A SOQL query against an external object usually causes a live request through Salesforce Connect. The __x suffix identifies an external object, while custom fields commonly use __c.
SELECT ExternalId, DisplayUrl, Name__c, Price__c
FROM Product__x
WHERE Price__c > 100
ORDER BY Name__c
LIMIT 20Apex can query the same object. If the data source supports writes, Database.insertImmediate sends a record to that system immediately.
Product__x product = new Product__x(
Name__c = 'Widget',
Price__c = 25
);
Database.SaveResult result = Database.insertImmediate(product);
if (!result.isSuccess()) {
System.debug(result.getErrors()[0].getMessage());
}Limits and custom adapters
Live data avoids storage duplication, but each request depends on the external system. Large list views, broad queries, slow endpoints, and restrictive remote APIs can cause poor performance or failures. Copy data into Salesforce when users need fast, heavily joined, offline, or reporting-intensive access.
For an unsupported source, the Apex Connector Framework provides a custom adapter. A provider declares authentication and query capabilities. Its connection class implements sync() to describe tables and columns, then implements query() to return rows and apply query filters.
| Adapter part | Main responsibility |
|---|---|
| Provider | Declares capabilities and returns a connection |
| Connection | Describes schema and retrieves rows |
Exercise
Which relationship should match an external record to a Salesforce record using a shared external ID?
Show answer
An indirect lookup relationship.