Sub topic 9
Showing external data in tabs, layouts, and list views
External objects exist in Salesforce as metadata only, so nothing shows up for users until you expose them. This chapter covers the three surfaces that do that: tabs, page layouts, and list views. It also covers the related setup that makes them behave: compact layouts, search, and app navigation.
This chapter assumes you have already created an external data source and generated an external object with Validate and Sync. It also assumes you can use permission sets and App Manager in Setup. The examples use the Product__x object from earlier chapters.
What users see and what Salesforce stores
Each time a user opens a tab, a list view, or a record page, Salesforce sends a live request to the external system. Nothing is cached as a record in your org. This has three consequences for the UI work in this chapter:
- Every page that shows external rows depends on the external system being up and fast.
- Every field you put on a layout or list view is a field the external system must return.
- Features that depend on data stored in Salesforce, such as record ownership, are missing or limited.
The path from object to user
Validate and Sync creates the external object, but users see nothing until four steps are done. The first three can be done in any order, but all must be finished before a user can use the object.
Creating a tab
External objects do not get a tab automatically. You create one the same way as for a custom object.
- In Setup, search for Tabs.
- Under Custom Object Tabs, click New.
- In the Object list, pick the external object. Its API name ends in
__x. - Choose a tab style, which sets the color and icon.
- Save.
Creating the tab does not make it visible to anyone. Visibility has two parts:
- Tab setting on a permission set. Set it to Available (the user can add it) or Visible (it shows by default). Hidden removes it.
- App navigation. In Lightning Experience, a tab appears in the navigation bar only if the app includes it. In App Manager, edit the app, open Navigation Items, and move the tab into the selected list.
A common mistake is to fix object permissions and forget the tab. The user can then run SOQL against the object but has no way to open it in the UI. Object-level access, covered in the previous chapter, is a prerequisite for the tab, not a substitute for it.
Page layouts
An external object has page layouts like a custom object. Open the object in Object Manager, then go to Page Layouts. The layout editor offers only the fields that Validate and Sync created, plus a few standard ones.
Fields on the layout
- ExternalId is the unique key of the row in the external system. It is usually not meaningful to users, so most layouts leave it off the form.
- DisplayUrl is a URL field that links to the record in the external system. It is useful when the source system has its own detail page. It is an ordinary field, so you control whether it appears.
- The field you chose as the name field when you ran Validate and Sync is used as the record title. Pick a field that identifies the row to people, such as a product name. An opaque code makes every list and lookup hard to read.
- Each custom field ends in
__c, the same as on custom objects. Only fields that were synced can be added.
Buttons and related lists
On a read-only external object, New, Edit, and Delete do nothing useful. Remove them from the layout unless you enabled writes, which a later chapter covers.
Related lists work in two directions:
- On an external object layout, you can add related lists for Salesforce objects that point to the external record through an external lookup. Salesforce shows the child rows, and the parent comes from the external system.
- On a Salesforce object layout, such as Account, you can add the external object as a related list when an indirect lookup or external lookup connects them. Each time the page loads, Salesforce calls the external system for the matching rows.
Every related list is another live callout. Several of them on one page multiply the number of requests and the wait. Add only the ones users really need.
Lightning record pages
In Lightning Experience you can also edit the record page in Lightning App Builder. You can arrange components in tabs and sections, and use visibility rules, as with other objects. The page layout still controls which fields the Details component shows. Edit the page layout first, then adjust the Lightning page.
Compact layouts and search layouts
- A compact layout sets the highlights panel at the top of the record and the fields shown in lookup hover cards. Choose three to five fields that identify a row.
- A search layout sets the columns for lookup dialogs and search results. If users pick external rows from a lookup dialog, define it, or the dialog shows only the name field.
List views
A list view is the easiest way to give users a working table with no code. Create one from the tab by choosing New in the list view controls.
| List view feature | Behavior on external objects |
|---|---|
| Filter by field values | Supported. Salesforce sends the filter to the external system as part of the request. |
| Sort by column | Supported on fields the external system can sort. |
| Visible fields | Any synced field. Fewer fields means a smaller response. |
| Filter by owner ("My", "All") | Not available. External objects have no owner field. |
| Visibility | Choose who can see the view, as with other objects. |
The filter clause is turned into a query for the external system. This list view filter corresponds to the SOQL shown here:
SELECT ExternalId, Name__c, Price__c
FROM Product__x
WHERE Price__c > 100
ORDER BY Name__c
LIMIT 20Behavior depends on the adapter. The OData adapters translate the filter into an OData $filter and the sort into $orderby. A custom Apex adapter applies filters only if its code does. The sample adapter in an earlier chapter uses DataSource.QueryUtils.process, which filters in memory after fetching the rows. For a large source, that is slow.
Working with large results
- Put selective filters in the default list view, so the first page the user sees is small.
- Do not rely on exact record counts. Many external systems do not report a total, so the UI may show less count information than for a standard object.
- Page size is limited, and the external system may cap it lower. Users who need the full set should use a report or export from the source system instead.
Search
By default, external objects are not part of global search. To include one, enable search on the external data source and on the external object's definition. Then check the result in the UI. External search sends a live request on each search, and the external system must support the filtering the adapter sends. If your source has no usable search capability, leave search off, since a slow or failing search spoils the experience for every other object too.
Checklist for a first release
- Name field is a readable column.
- Tab created and added to the right app.
- Permission set has object read, field read, and tab visibility for the target users.
- Page layout has only the fields and related lists you need. Edit, delete, and new buttons are removed when the object is read-only.
- Compact and search layouts are defined.
- A default list view has a selective filter.
- Test with a user who has only the permission set, not with an admin.
The last item matters most. Admins see more by default, so a layout that works for you can look empty or fail for a normal user.
Common problems
- The tab is missing. The permission set does not set the tab to Available or Visible, or the app does not include it.
- The list is empty and shows no error. The user lacks field access to the filtered or displayed fields. The external system may also have rejected the request, so check the data source credentials.
- A page loads slowly. Count the related lists and fields. Each one is a callout.
- Lookups show an unreadable value. The name field is an ID. Re-sync with a better name field, or add a search layout.
- A field you want is not on the layout. It was not synced. Run Validate and Sync again after the source schema changes, then add it.
Exercise
A user has read access to Product__x and all of its fields, but cannot find the object in the Lightning navigation bar. Name two settings you would check, and explain why object access alone is not enough.
Show answer
Check that a custom object tab exists for Product__x and that the user's permission set sets the tab to Available or Visible. Also check that the Lightning app the user works in lists the tab under Navigation Items. Object and field permissions control what data the user may read. Tabs and app navigation control where the object appears in the UI, so access to the data does not create a way to open it.
Exercise
You build a record page for Product__x and add five related lists. Users complain that the page takes eight seconds to load. What causes it, and what do you change?
Show answer
Each related list on the page triggers its own live request to the external system, so the page waits on several callouts and their total time. Remove related lists that users rarely need, reduce the fields each list shows, and make sure each query is filtered so the source returns few rows. If the content is still needed, consider moving it to a separate tab so it loads only on demand.
Exercise
Why can you not create a list view that filters Product__x rows to "My products"?
Show answer
External objects have no owner field, because the records are not stored in Salesforce. The "My" and owner-based filters depend on an owner, so you need a filter on an external field instead, such as a category or a supplier code.