function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BobPBobP 

flow's wrapped in lightning component finish behavior return to home

I am working on a flow wrapped in a lightning component as a global action and i am trying to figure out how to change the finish bahavior so the user is redirected to the home page. I came across these events ( force:navigateToObjectHome or force:navigateToUrl.) but I'm not sure where to used them in my lightning component. Any help with this would be greatly appreciated. My code is below for my component

Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >

<aura:handler name="init"  value="{!this}" action="{!c.init}" />
<lightning:flow aura:id="flowData" />
</aura:component>

Controller:
 
({
init : function (component) {
// Find the component whose aura:id is "flowData"
var flow = component.find("flowData");
// In that component, start your flow. Reference the flow’s Unique Name.
flow.startFlow("New_IT_Support_Case");
   
},
})



 
lkatneylkatney
Hi @Bob,

Please find the answer to your question in below link:

https://developer.salesforce.com/docs/atlas.en-us.216.0.salesforce_vpm_guide.meta/salesforce_vpm_guide/components_using_flow_onfinish.htm

Thanks
BobPBobP
Thank you for helping 
lkatney,


I tried using the code from that example.
Component:
<aura:component access="global">
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}" />
</aura:component>

And I added this to the Controller:
 
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "FINISHED") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "redirect") {
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,
               "isredirect": "true"
            });
            urlEvent.fire();
         }
      }
   }
}

When I save the component I get the following error below.
User-added image

Do i need to customize some of the code to the name of my flow? I'm not sure what to do with that code.