Using Flow to Refresh Page Data

Using Flow to Refresh Page Data

There are many use cases where we put screen flows on record pages to guide users through business processes. Depending on the requirements, these screen flows may have multiple screens. Moreover, at different stages, they may perform updates to the open record or to records in related lists on the current page. The issue is that the page does not reflect the new updates immediately, but only when the flow finishes. Another issue is with screen flows that end with a screen that has no finish button. In this case, the page will not refresh since it never hits the "finish" point. In order to solve this issue, you can use this custom component. This component allows admins to trigger a seamless page data refresh from a flow, without having to reload the entire page. Therefore you won't lose your progress in the flow, and still see the updated data on the page.

Components of the Package

This package includes 2 different components that can be used to refresh the page data. The first one is a local action that is available in screen flows. The second one is a Lightning Web Component (LWC) that you have to put on a page. This LWC listens for a platform event that you can publish when you need the data refresh.

How to Use the Local Action

This method is pretty straightforward. Simply add the "Refresh Page Data" local action to your screen flow, and no additional configuration is required. Note that this method works for screen flows only.

Refresh Page Data - Local Action

How to Use the Lightning Web Component

This method works for all flow types (except before-save flows, since they do not support the "Create Records" element). Moreover, it even works with Apex (later on about that).

First of all, add the "Platform Event Refresh Page Data" component to the Lightning Record Page. This component will allow you to trigger a data refresh whenever you publish a "Refresh Page Data" platform event.

Platform Event Refresh Page Data

To publish a platform event from flow, use the create records element and create a "Refresh Page Data" record. Set the RecordId__c field to the Id of the relevant record that you want to refresh. The refresh will happen for the running user only, and not for the other users. Once you have set up the flow, page data will refresh automatically whenever you publish a platform event.

Publish a Platform Event to Refresh Page Data

If you want to use an Apex code instead of a flow, here is how you can publish the platform event.

Refresh_Page_Data__e refreshEvent = new Refresh_Page_Data__e(RecordId__c = '<record_id>');

Replace <record_id> with the id of the record that you want to refresh.


In this example, whenever you change the opportunity stage to Closed Won, the system makes an asynchronous callout. It is possible to see the status of the interface from a field called SBO Quote Sync Status. However, since it is asynchronous, it is not possible to see the updated value without refreshing the page.

By publishing a platform event (and using the LWC on the record page), it is possible to refresh the page data. See how SBO Quote Sync Status field changes.

Refresh Page Data Example

Important Notes

Although the second method will work also for screen flows, it is better to use the local action when using a screen flow for a number of reasons.

  • It does not consume from the platform events limit (read more about platform event limits here).
  • It does not require adding an additional component to the lightning page.
  • Although platform events are usually published and received very quickly, this method is still faster.

It is recommended to add the component at the very top of the page. This way you can ensure the component is not lazy-loaded as the user scrolls through the page.


  • There is a limit to the number of platform events one can publish and subscribe to. It depends on the Salesforce edition, and on the existence of an add-on license.
  • If the limit is reached, the page will not refresh anymore when you publish a platform event.
  • The platform event-driven component does not support mobile devices, since the empAPI library is not supported on mobile, and there isn't a known alternative.

Installation Links

Use this link to install in production or developer edition environments.

Use this link to install in sandbox environments.

Be the first to comment

Leave a Reply

Your email address will not be published.