[SalesForce] Flow wrapped in a lightning component used as a Global Action Button not closing flow screen

I adjust my flow and it does work where a case is created and it redirects to a newly created case with no other screen works when i add the lightning component to my lightning home page layout.

But, It is very odd when executing the same flow from a Global Action menu it still works but there is a Finish button at the end of the flow and then it returns back to the beginning of the flow. See Screen shots below.

I don't know if there is something else I can add to change the behavior in the lightning component global action button to perform like it does on the home page or outside of the global action button.

End of Flow
Flow Case Screen

Flow Beginning Screen

Lightning Component Code

 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickAction" >

<!-- Initialize the component to show the flow -->
<aura:handler name="init" value="{!this}" action="{!c.init}" />

<!-- The marker for the flow. with a listener on the status change -->
<lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}" />
    <br/>

</aura:component>





({
/* Launch the correct flow */
  init : function (cmp) {
    var flow = cmp.find("flowData");
    flow.startFlow("New_IT_Support_Case");

  },

/*On change listener*/
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "Next") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "New_IT_Support_Case") {
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,

               "isredirect": "true"
            });

         }

      }        

   }          

}


})

Best Answer

Thank you for helping me. I was able to resolve my requirements by updating my code to the following.

({
/*Launch the correct flow */
  init : function (cmp) {
  var flow = cmp.find("flowData");
  flow.startFlow("New_IT_Support_Case");    
},

/*On change listener*/
handleStatusChange : function (component, event) {
 if(event.getParam("status") === "Next") {
    var outputVariables = event.getParam("outputVariables");
    var outputVar;
    for(var i = 0; i < outputVariables.length; i++) {
     outputVar = outputVariables[i];
     if(outputVar.name === "New_IT_Support_Case") 
       $A.get("e.force:closeQuickAction").fire();
    }
   }
  }       
})
Related Topic