Control What Happens When a Flow Interview Finishes
By embedding a flow in a custom lightning-flow component, you can shape what happens when the flow finishes.
To use this component, build a flow with the Salesforce Flow Builder first. The component includes the navigation buttons Back, Next, Pause, and Finish.
If your flow has custom Lightning web components or Aura components, then you can’t use lightning-flow on Experience Cloud sites that use Lightning Web Runtime.
Note
Embed a Flow using lightning-flow
By default, when a flow user clicks Finish, a new interview starts and the user sees the first screen of the flow again. By embedding a flow in a custom lightning-flow component, you can shape what happens when the flow finishes by using the onstatuschange event handler.
1// myComponent.js2handleStatusChange(event){3 if(event.detail.status === 'FINISHED'){4 // Redirect to another page in Salesforce., or5 // Redirect to a page outside of Salesforce., or6 // Show a toast, or something else7}8}
Example: Navigate to a Record When the Flow Finishes
This example redirects the user to a case created in the flow by using the lightning/navigationNavigationMixin.Navigatemethod.