I have an aura component that currently overrides the New Case button, works great. But when the screen flow runs and gets to the end of the flow tree, I have a screen that says "your case has been created" but when you click Finish, it starts the flow over again. How do I make this stop and redirect to the record it created?
<aura:component implements="lightning:actionOverride" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<lightning:card>
<lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}"/>
</lightning:card>
</aura:component>
({
init: function(component) {
let objFlow = component.find("flowData");
objFlow.startFlow("New_Case");
}
})
Hi Staci,
This is actually expected behavior with lightning:flow when it's embedded in an Aura action override — the flow component automatically restarts itself when it hits FINISHED status unless you explicitly intercept that and close/navigate away yourself. The "Open a Page" flow action alone won't stop the restart because it doesn't control the lifecycle of the Aura component hosting it — it just navigates in a new context while the underlying flow component is still mounted and reacts to its own FINISHED status by resetting.
The fix: handle the status change in your Aura controller, not just via a Flow action.
1. Get the new record's Id as a Flow output
In your Screen Flow, create an output variable (e.g., recordId, of type Text) and set it to the newly created Case's Id right after the Create Records element.
2. Update your Aura component's onstatuschange handler
Instead of relying solely on the flow's internal navigation action, catch the FINISHED status and manually close the action + navigate. Replace your controller's handleStatusChange function with this:
handleStatusChange: function(component, event, helper) {
if (event.getParam("status") === "FINISHED") {
var outputVariables = event.getParam("outputVariables");
var recordId;
for (var i = 0; i < outputVariables.length; i++) {
if (outputVariables[i].name === "recordId") {
recordId = outputVariables[i].value;
}
}
// Close the modal or action panel
$A.get("e.force:closeQuickAction").fire();
// Navigate to the newly created record
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": recordId,
"slideDevName": "detail"
});
navEvt.fire();
}
}
3. Remove or skip the "Open a Page" flow action
Since navigation is now handled entirely in the Aura controller based on the FINISHED status, you don't need the Flow's own "Open a Page" element pointing at the record. That element was likely what caused the double behavior, since the flow tries to navigate and then restarts because the component underneath is still alive.
The restart happens because lightning:flow treats "Finish" as "ready to run again" by default when embedded, since it is designed for cases where you want to allow re-running the same flow instance, such as a "create another case" style behavior. By explicitly firing force:closeQuickAction as soon as you detect FINISHED, you tear down the Aura component or modal entirely before it gets a chance to reset, so there is nothing left to restart.
This pattern of catching FINISHED, closing the quick action, then navigating is the standard approach for this exact New or Edit button override plus Screen Flow plus redirect scenario.