Refresh a Lightning Page from a Screen Flow
If a Screen Flow updates a record and the surrounding page stays stale, use an LWC local action to refresh the current Lightning view.
Recommendation
Use an LWC local action (lightning__FlowAction) that dispatches RefreshEvent from lightning/refresh.
For an approval flow embedded on a record page, this is usually the right behavior.
It keeps the user on the same page and asks Lightning to reload the view state around the flow.
Debug Mode
I would expect this to behave better in Flow debug than a hard reload, because it is not trying to reload the entire debugger page.
But Flow debug is still not the same as running inside a normal Lightning record page. So test it there too.
Build the LWC
Create an LWC component named flowViewRefresher.
flowViewRefresher.html
<template></template>
flowViewRefresher.js
import { LightningElement, api } from 'lwc';
import { RefreshEvent } from 'lightning/refresh';
export default class FlowViewRefresher extends LightningElement {
@api
invoke() {
this.dispatchEvent(new RefreshEvent());
}
}
flowViewRefresher.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowAction</target>
</targets>
</LightningComponentBundle>
Configure in Flow
- Add an Action element after the approval step.
- Search Local Actions for
flowViewRefresher. - Run the flow from the real Lightning page and confirm the approval state updates as expected.
- Also test in Flow debug so you know whether your org's debugger host behaves cleanly with view refresh.
Why This Shape
This works well because:
- it is a proper LWC Flow Action, not a workaround screen component
- it refreshes the Lightning view instead of hard-reloading the whole browser tab
- it fits approval flows well, where the page usually just needs to reflect updated status
Older Aura Pattern
Older examples often use an Aura local action with window.location.reload().
That made sense at the time. Aura local actions existed much earlier, while direct LWC local actions for Screen Flows arrived later.
If a hard reload is good enough for your use case, the Aura version can still work. But for new work, I would start with the LWC refresh pattern above.
When You Still Need a Hard Reload
Use window.location.reload() only if a view refresh is not enough.
A hard reload can reopen action-launched flows because the browser reloads the action URL, not the underlying record page.
Related
Part 2: Older Flow Screen Workaround
If the flow runs inside a host that does not execute direct LWC Flow Actions cleanly, the older workaround is to use an LWC screen component instead.
This is the pattern where you add a final Screen element, place the component on that screen, and let the component refresh the page as soon as it loads.
flowScreenViewRefresher.html
<template></template>
flowScreenViewRefresher.js
import { LightningElement } from 'lwc';
import { RefreshEvent } from 'lightning/refresh';
export default class FlowScreenViewRefresher extends LightningElement {
connectedCallback() {
this.dispatchEvent(new RefreshEvent());
}
}
flowScreenViewRefresher.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowScreen</target>
</targets>
</LightningComponentBundle>
Configure the Older Workaround in Flow
- Add a final Screen element after the approval step.
- Drop
flowScreenViewRefresheronto that screen. - Keep the screen otherwise empty.
- Test it inside the real Work Guide host, not just in Flow debug.
This is less elegant than a true Flow Action because the screen exists only to mount the component and trigger connectedCallback().
But if your flow is running inside Work Guide, this workaround may be more reliable because Work Guide already knows how to render Flow screen components.
Resources
- Salesforce Developers: Refresh Component Data with RefreshView API
- Salesforce Developers: lightning__FlowAction Target
- Salesforce Developers: lightning__FlowScreen Target
- Salesforce Time: A Flow Action to Refresh the Page