Salta ai contenuti

Platform Events in Flow

Questi contenuti non sono ancora disponibili nella tua lingua.

Module 5 of 6 in the chapter The Admin’s Integration Toolkit, chapter 4 of the Integration Architect course. Each module stands on its own. Previous: Who’s Calling In · Next: What You’ll See When It Breaks

The question this module answers: How does a flow tell other systems that something happened, without calling any of them?

In modules 1 to 3, the flow called the other system. It needed the address, the named credential, the right request, and a plan for the answer. That’s request and reply: you ask, and you wait.

Sometimes you don’t need an answer. A delivery is running late, and Redrock, the customer team and the warehouse all want to know. You could call each one. Or you could say it once, out loud, and let whoever cares pick it up. That’s a platform event. As I put it in class: fire and forget. Once the event goes out, you’re done. You move on.

First, define the message. From Setup, go to Platform Events and choose New Platform Event. Steve Trucking’s is called Delivery Update.

It looks like an object, but it’s not. Its API name ends in __e, not __c: Delivery_Update__e. You add fields to it the way you would to an object: a Delivery Number, a Status, a New ETA.

But only some kinds of fields. Salesforce allows checkbox, date, date/time, number, text and long text area (Platform Event Fields (opens in a new tab), Platform Events Developer Guide, checked 2026-11-01). No picklists, no lookups, no master-detail. That’s on purpose. This event is going to leave Salesforce and go to other systems, so it needs to survive on its own outside of Salesforce. A lookup means nothing to Redrock. A delivery number does.

Publishing is a step you already know. In Salesforce’s words: “add a Create Records element to the appropriate flow. Where you’d usually pick an object to create, select the custom platform event” (Publish Event Messages with Flows (opens in a new tab), checked 2026-11-01).

So Steve Trucking adds a record-triggered flow on the delivery: when the ETA moves later, create a Delivery Update with the delivery number, the status and the new ETA. Save, activate, done.

Look at what’s missing. No address. No named credential. No fault path for Redrock being down. When a flow publishes onto the event bus, all of a sudden it doesn’t need the connection, the credential or the error handling. Those are now the listener’s job.

One setting to choose on the event itself: when it goes out.

  • Publish Immediately is the default, and Salesforce recommends it for most events. The event goes out when the flow publishes it, “regardless of whether the transaction succeeds.” So a listener can sometimes get the event before the delivery record is saved.
  • Publish After Commit waits until the record is saved, and isn’t published at all if the save fails. Salesforce’s advice: choose it “only if the subscriber requires committed transaction data.”

If Redrock will call back to read the delivery when it hears the event, choose Publish After Commit, so the delivery it reads is the one that was saved.

Now, who hears it?

Inside the org, a flow can listen. Create a platform event–triggered flow, and in its Start element choose the Delivery Update event. The event’s fields are in $Record, the same way a record’s fields are in a record-triggered flow (Subscribe to Platform Event Messages with Flows (opens in a new tab), checked 2026-11-01). Steve Trucking’s tells the customer team that the delivery is late.

A flow that’s already running can listen too. Add a Pause element, choose the event, and set which values it waits for: this delivery number, say. When a matching event arrives, the flow picks up where it stopped.

Outside the org, Redrock’s system can listen. It subscribes to the event through the Pub/Sub API, signing in through its External Client App as its integration user, from module 4.

One event, many listeners Inside Steve Trucking's org, a delivery is running late. A record-triggered flow publishes a Delivery Update event, with a Create Records element. The event, in navy, sits on the event bus, published once. Two listeners hear it. Inside the org, a platform event–triggered flow starts and tells the customer team. Outside, Redrock's system, which subscribes through the Pub/Sub API, connects in, and the event comes out to it. Underneath: the publisher doesn't know who's listening; each subscriber picks the event up on its own. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.52.0", "built": "2026-10-29", "id": "DGM-INT-AT-12", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.4.0", "theme": "stevetecharc 1.4.0"} IN SALESFORCE: STEVE TRUCKING REDROCK'S SIDE A delivery is running late a record-triggered flow, with Create Records The Delivery Update event on the event bus published once A platform event–triggered flow tells the customer team Redrock's system subscribes through the Pub/Sub API publishes starts the flow Redrock connects in; the event comes out The publisher doesn't know who's listening. Each subscriber picks the event up on its own. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

One event, many listeners.

Notice which way Redrock’s arrow works. The event goes out to Redrock, but Redrock is the one that connects in. If I want to send a package to you, I could find your address, put it in a car and drive it to your house. With an event, it’s the other way around: you drive to my house, say “I’m here,” and I hand you the package. So Redrock does the driving, the reconnecting and the error handling. Salesforce just hands over what’s waiting. That’s why so many people draw this arrow the wrong way. Chapter 11 takes it apart.

And the publisher doesn’t need to know who’s listening. The flow that publishes Delivery Update doesn’t know about the customer team’s flow or Redrock. One admin can write the publisher this year, and another can add a listener next year. They never have to coordinate. That’s loose coupling, and it works inside the org as well as out: one flow publishes an error event, and one central error-handling flow listens to it, instead of every flow calling it as a subflow.

A platform event–triggered flow isn’t part of the save that published the event. Salesforce lists what that means (Subscribe to Platform Event Messages with Flows (opens in a new tab)):

  • It runs later, on its own. Each one “runs asynchronously in a separate transaction from the transaction that published the event message.” There can be a delay. That’s also why a separate transaction gets its own limits.
  • It gets events in batches, up to 200 at a time, in the order they were received.
  • It runs as the publisher. Its debug logs are under the Automated Process user, “but each flow interview runs in the context of the user who published the event message.” If it creates a record, the record’s Created By is the user who published.
  • Nothing tells you if it never starts. “If an event fails, the flow doesn’t start. Because the flow is never triggered, a flow error email isn’t sent.” Look at the event’s errors instead. More on that in the next module.
  • No order between listeners. If several flows listen to the same event, Salesforce can’t guarantee which one handles each event first. Don’t build one listener that depends on another having run.

This is a very basic question, and every event designer meets it: what do you put in the event?

Think of the event as a package. The package is only so big. If you can fit everything in it, ship it: the delivery number, the status, the new ETA, the customer, the stops. Redrock can act on it as soon as it arrives, without spending API calls coming back to Salesforce. The downside is that a package can sit and wait. If Redrock’s system is down for twelve hours, the ETA in the package may already have changed when Redrock reads it.

If it doesn’t fit, or if it has to be fresh, send just the ID. The event only says that something happened: delivery D-1042 changed. Redrock calls back, through the REST API, and gets the delivery as it is now. That’s fresh, and it costs a call.

The whole package or just the ID Two panels side by side. The whole package, in blue, everything in the event: ready to act on when it arrives; no call back and no API calls spent; only as big as the event allows; and it can be out of date by the time it's read. Just the ID, in cyan, a note that something happened: small and quick to send; the subscriber calls back for the rest; each call back is an API call; and what it gets is fresh. Underneath: if it fits, ship it; if not, send the ID and let them come and get it. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.52.0", "built": "2026-10-29", "id": "DGM-INT-AT-13", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison/side-by-side 0.5.0", "theme": "stevetecharc 1.4.0"} The whole package everything in the event Ready to act on when it arrives No call back, no API calls spent Only as big as the event allows Can be out of date when it's read Just the ID something happened Small, and quick to send The subscriber calls back for the rest Each call back is an API call What it gets is fresh If it fits, ship it. If not, send the ID and let them come and get it. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

The whole package or just the ID.

Neither is wrong, and you can mix them: carry the few fields most listeners need, and the ID for the rest. And if listeners call back, remember the publish setting above: Publish After Commit, so there’s a saved record to read.

This module is the admin’s half. Chapter 11 is the rest: the event bus itself, the Pub/Sub API, how a listener that was away catches up, how long events are kept, how many can go out to other systems, Change Data Capture, and what happens when the event bus meets other companies’ event buses.

  • For each change other systems care about: an event, or a call. Do you need an answer, or just to say it happened?
  • Each event’s fields: what a listener needs to act, and whether it can survive outside Salesforce.
  • The whole package or just the ID, and what that costs the listeners.
  • Publish Immediately or Publish After Commit, for each event.
  • Who listens to each event, inside and outside the org, and who owns each listener. Write it down: the publisher can’t tell you.
  • How you’ll know when a listening flow never ran.

Beyond the exam: what AI changes. An agent that can run a flow can publish an event, and everything listening will react, inside the org and out. The publisher doesn’t know who’s listening, and neither does the agent. So the list of events and their listeners matters more, not less: it’s how you know what one action by an agent will set off. And AI is good at drafting that list from your org’s flows, if a person checks it.