OBLYTECH Logo
OBLYTECH Logo

When a Waiting User Should Not Depend on an Event

Avoid event-driven designs when a person is waiting for an immediate answer. Events run asynchronously, so the user cannot see the outcome in the same step, and failures surface later. When the next screen, price, approval or error message depends on the reply, use a synchronous call that returns a result or an error in the same request.

What an event-driven design does with a request

In an event-driven design, a system publishes a message after something changes, and one or more subscribers pick it up when they are ready. The publisher does not wait for them. That decoupling is the point: the publisher finishes its own work, and each subscriber processes the change on its own schedule.

Salesforce offers several ways to publish. Platform events and Change Data Capture are the preferred mechanisms when record and field changes need to reach other systems. For new publish/subscribe work, the Pub/Sub API is the recommended interface, while PushTopic and generic events are not recommended for new builds. Publishing an event tells other systems that something happened. It does not hand the user who triggered the change the result of what those systems do with it.

Signs that a waiting user should not depend on an event

Many cases become clear once you walk through the user’s steps. Look for these signs:

  • The user’s next action needs a value that another system has to produce first.
  • A failure has to be shown to the person in the same session, with a message they can act on.
  • The user is deciding on the result, such as a quote, an eligibility check or an approval.
  • The save should not complete until an external system has confirmed something.
  • The user would otherwise be sent to a second screen or told to check back later for the outcome.

If one of these applies, treat that step as synchronous, even when the rest of the integration is event-driven. That split is usually easier to support than forcing the whole flow into one style.

Why asynchronous delivery fails the waiting user

The main problem is timing. Event-driven architectures are built for asynchronous execution, and they should not be used for processes that demand an immediate, synchronous human response. A subscriber might process a message in seconds or in an hour, and the user has no reliable way to tell which. That gap makes the screen feel broken, even when the integration works as designed.

Delivery carries its own risk. If a subscriber is offline when a critical message is published, the message may not reach it unless you use replay functionality or run redundant subscribers on separate servers. A waiting user gains nothing from either safeguard, because the failure shows up as a missing result rather than a visible error.

Scale adds a third issue. As an event-driven architecture grows, the event bus can become a bottleneck when it is overwhelmed. Queues absorb surges by holding excess messages, and they suit cases where added latency causes no problems downstream. For a person waiting on a screen, latency is the problem itself. A queue that absorbs a spike moves the wait onto the user.

Synchronous patterns that still fit a Salesforce landscape

A synchronous call sends a request and waits for a response that carries the answer or an error. In practice that usually takes one of three shapes: a callout made from Apex during the user’s action, a request from the user interface to an external API, or a call through an integration layer that returns a response to the caller. The right shape depends on where the logic already lives and who owns the target system.

Check the current callout rules for your org’s edition and release before committing to a design, because they determine what can run inside the user’s transaction. Keep the call small. Ask the target system for just the fields the screen needs, and avoid chaining several synchronous calls one after another, since each adds wait time and another point of failure.

If your landscape already has an integration layer, route the synchronous call through it rather than building a second path to the same system. For help planning this work, see Salesforce implementation.

Designing the synchronous call so the user is not stranded

A synchronous path needs the same care as the happy path. Settle these decisions before the build starts:

  1. Set a timeout that matches what the user will tolerate on that screen, and test it against the slowest response the target system can produce.
  2. Define the response shape the screen needs, including error values, so the user sees a specific message instead of a generic failure.
  3. Decide whether the save continues, stops or is marked pending when the call fails. Make that decision per field or step, not once for the whole form.
  4. Retry calls that are safe to repeat. A retry that creates a second record does more harm than a clear error.
  5. Log the request and its outcome together, so a support person can match a complaint to one specific call.

Without a shared identifier between the user action and the log entry, a support team cannot tell whether a timeout came from the target system, the network or the screen.

Checking limits, validation and access on the save path

A synchronous call runs inside the transaction of the user’s action, so its time and resource use can count against the limits for that transaction. Check those limits for the context where the call runs, and confirm the callout does not sit behind a long chain of automation that already uses much of the budget. For the limit checks themselves, see Salesforce governor limits for admins.

Validation rules can change the outcome too. If a rule blocks the save before the external answer arrives, the user sees the rule’s message rather than the integration’s. List which rules fire on the object, then decide whether an external check should run before them or after. For the sequencing details, see validation rules without breaking integrations.

Access is the last check. The user’s session may not be able to read the fields the call uses, and the integration user may need its own access. Give that user a permission set scoped to the objects and fields the call needs, which is easier to audit than a broad profile change. For how to structure those sets, see permission set design for small teams.

Testing the decision before the build

Test the design against the user’s path, not just the integration. Walk through each step on the screen and mark each point where the user needs a result before continuing. Those are the steps where a synchronous call belongs, and where a failed call needs a visible response.

Then test the failure cases. Stop the target system, slow it down, and return an invalid response. Confirm that the screen shows the message you designed, that the record stays in the state you planned, and that the log has enough detail to trace the request.

Schedule testing around sandbox refreshes. Set refresh dates that do not fall in the middle of an integration test cycle. Record which endpoint each test org calls, so no test org is pointed at production by mistake. For timing, see sandbox refresh planning.

When an event-driven step still belongs after the answer

Once the user has their answer, events are often the right tool for everything that follows. A confirmed order can publish an event that tells a fulfillment system, a billing system and a reporting process what changed. The user does not wait for those systems, and each subscriber can process the change at its own pace.

This split keeps the user path short and the background path resilient. The synchronous call answers the question in front of the person, and the event carries the change to everything else. Keep the two paths separate in the design document, so the answer does not drift behind an event later.

Questions about choosing a synchronous call for user-facing steps

Can a status message stand in for a synchronous response?

A status message tells the user that work is underway, which helps. It does not give them the answer. If the next step depends on the result, the user still has to wait for a second signal, and the screen must check for it. A synchronous call removes that second step for the person using the screen.

What should happen when the external system is slow?

Set the timeout from the user’s tolerance, then choose a fallback for each step. The fallback might block the save with a clear message, or let the save finish and mark the outcome as pending. Record the choice per step so support staff know what the user saw.

Should a failed call roll back the whole save?

Stop the save when the saved data depends on the answer. If a price or approval must be confirmed before the record is valid, the record should not be saved without it. If the answer just enriches the record, save the record and mark the enrichment as pending. Do not apply one rule to the whole form by default.

Do platform events have any role on a waiting user’s screen?

Yes, after the answer is settled. Use an event to notify other systems that the user’s action completed, not to deliver the answer the user needs now. That keeps the waiting part of the flow direct and lets the background work run without holding the screen.

Is a scheduled batch job a better option for a waiting user?

No. A batch job runs on a schedule, so the user cannot wait for it to finish. Batch processing suits work that can wait for the next scheduled run. When a person is waiting, the answer has to come from a call that completes inside the session.