Hoppa till innehåll

A Component That Reads Live

Det här innehållet är inte tillgängligt på ditt språk än.

Module 5 of 6 in the chapter Data Connectivity and Virtualization, chapter 19 of the Integration Architect course. Each module stands on its own. Previous: Your Own Adapter: the Apex Connector Framework · Next: Hybrids with Today’s Tools, and the Quick-Start Lab

The question this module answers: When the data doesn’t fit an external object, how do you build a component that reads it live, shows it and saves nothing, and what does every live read have to handle?

In class, after we build external objects, I ask the room: how might I show that data on the screen without Salesforce Connect? Somebody always gets there. You could call out and do a get when you need to see something. And where would you put it? In a Lightning web component.

That’s virtualization you build yourself. The component calls out in real time, renders the answer in the page, and the data stays somewhere else. Nothing is saved in Salesforce.

When to choose it over an external object is a design decision, and Data Architect chapter 14 takes it apart from the page’s side, with the story of a customer whose data was satellites and beams and didn’t fit rows and columns at all (Salesforce Connect or a Component?). This module is how you build it, and what it has to handle.

Here’s what happens when a coordinator opens a record and the component loads.

  1. The component asks Apex. The Lightning web component on the record page calls an Apex method, passing the record’s key.
  2. Apex calls out, through a named credential. In class I ask: what’s a prerequisite to make a call out? Authentication. Where does it go? Named credentials. The address and the way to sign in live there, given only to the people who need them (chapter 9).
  3. The other system answers. Apex reads the answer and shapes it into exactly what the component shows: not the whole response, just the fields on the screen.
  4. The component renders it. When the page closes, it’s gone. Nothing was written to Salesforce.

Notice what didn’t happen: the browser never called the other system. The call went from the browser to Salesforce, and from Salesforce’s servers to the other system. That’s on purpose. If the browser called the other system directly, the credentials would have to be in the browser, the other system would have to accept calls from every user’s laptop, and the browser’s security rules would get in the way. Chapter 5 module 4 drew that line: the lateral call, through the server.

When the Other System Is Slow: Continuation

Section titled “When the Other System Is Slow: Continuation”

Now the problem that catches teams in production.

An ordinary Apex callout holds a server thread while it waits. Salesforce limits how many of those long waits can run at once in an org. Salesforce’s own example: a support page that gets warranty information from a web service, used by thousands of agents. “A hundred of those agents can click the same button… These hundred simultaneous actions exceed the limit of concurrent long-running requests” (Make Long-Running Callouts with Continuations (opens in a new tab), Apex Developer Guide, checked 2026-11-21).

The answer is a continuation: an asynchronous callout from the component, where Salesforce hands the wait to a separate service and calls your code back when the answer arrives. “By using asynchronous callouts, the requests aren’t subjected to this limit and can be executed.”

It has limits of its own (Asynchronous Callout Limits (opens in a new tab), checked 2026-11-21):

  • Up to 3 callouts in parallel in one continuation, and up to 3 chained one after another.
  • A maximum timeout of 120 seconds for a single continuation.
  • A maximum response of 1 MB.
  • When the answer comes back, “a new Apex transaction starts”, with fresh limits.

So if the other system can be slow, and many people will open the page at once, build the read as a continuation from the start. It’s much harder to retrofit after the first busy Monday.

In class I say that every time you make a callout, even just one, three questions have to go through your head. I use a simple example: a button that checks the weather. What if the weather service is down?

Where do I log it? A failed read should leave a record somewhere an admin can find it, with the time, the record and the error (chapter 14 module 2).

What do I tell the user who’s waiting? Not a spinner forever, and not a stack trace. Show the rest of the page, and a plain message in the component’s space: the shipment tracker isn’t answering right now. Size the timeout for a person waiting, seconds, not minutes (chapter 14 module 4).

Is there a retry? For a read, often it’s a “try again” link. If the read matters to a process, not just a person, ask whether it should be a live read at all.

A live component has no copy to fall back on. When the other system is down, that part of the page is empty. Decide with the business, up front, whether that’s acceptable.

Here’s the trade, in the terms I use with companies.

A component costs nothing extra in licences. Build the component, build the callout, set up the named credential. What do you pay for? The number of calls, on the other system’s side. And someone to build it and maintain it. With Salesforce Connect, it’s drag and drop: your admins and your visual programmers can maintain it, and you don’t have code and test coverage to carry. With a component, you need a programmer to maintain it.

And a component reaches fewer places. It shows data on the page where you put it. It doesn’t give you list views, reports, global search, lookups or flows over that data. External objects go more places than a component does (module 4).

That’s why the component wins when the data doesn’t fit a table, when one page combines several systems, or when the source speaks nothing an adapter can read. And it loses when people need to search, report or automate over the data.

Test knowledge. Know that a Lightning web component can show external data in real time through an Apex callout with a named credential, without storing it, and that the call goes through the server, not from the browser. Know that a continuation lets long-running callouts from a component avoid the concurrent long-running request limit, with its own limits (3 parallel callouts, 120-second timeout). Know what a component gives up compared with external objects: reports, list views, search and automation.

Beyond the exam: what AI changes. An agent answering “where’s my shipment?” makes the same live read a component does, and often far more of them: one question can become several calls. Every rule here applies to it too: through the server, through a named credential, with a timeout and a plain answer when the source is down. Data Architect chapter 14 warns about the load: agents don’t stop at ten rows.

  • Component or external object, from the shape of the data and what people need to do with it.
  • The path: component, Apex, named credential; never the browser straight to the other system.
  • Whether it’s a continuation, from how slow the source can be and how many people open the page at once.
  • The three answers: where failures are logged, what the user sees, and whether there’s a retry.
  • Who maintains it, and who pays for the calls on the other side.