0

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"
            });

         }

      }        

   }          

}


})

3 Answers 3

2

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();
    }
   }
  }       
})
2

The below code should be more than enough on finishing the flow.

handleStatusChange : function (component, event) {    
    //alert('event.getParam '+event.getParam('status'));
    if(event.getParam('status') === "FINISHED") {
        $A.get("e.force:closeQuickAction").fire();
    }        
}
1
  • This is the answer that worked for me - my flow did not show up when looping through the "outputVariables" in the other answers. Simply detecting the FINISHED action (caps important) and launching the close quick action worked great. Commented Feb 16, 2023 at 10:19
1

Any option selected from a global action first opens in a sidebar popup at the right bottom. The event e.force:closeQuickAction can be used in the Lightning component controller to close the popup either on click of 'Next' or 'Finish' or after a specific operation in the controller.

$A.get("e.force:closeQuickAction").fire();

4
  • Where would I use that in my controller? I've tried that and it did nothing, the flow went back to the beginning.
    – Bob P
    Commented Apr 27, 2020 at 13:24
  • Are you trying to redirect it to a newly created record? If yes, then don't think it would be possible by using e.force:navigateToSObject from a global action, since these events are only supported from record detail pages and not from global actions. You can try adding below code after the line 'if(outputVar.name === "New_IT_Support_Case") {' var url = window.location.href.substring(0, window.location.href.indexOf('.com')+4); url = url + '/' + outputVar.value; window.open(url, "_self"); Commented Apr 27, 2020 at 14:15
  • Hi Prakha, it doesn't need to get redirected to the newly created record. I just the need the screen to go away and not go back to the beginning of the flow. What happens now is the flow will execute but when i click the next button you can see it does redirect to the new case but the flow screen goes back to the beginning. So if i can just get the screen to close out when i user clicks next or finish, that would be my desired result.
    – Bob P
    Commented Apr 29, 2020 at 13:24
  • Would be great if you can upvote the answer. This way it would help others who are facing a similar problem. Thanks. Commented Sep 25, 2020 at 21:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .