1

I've searched and tested out many solutions listed on the site but still not able to have my Screen flow closed when calling from Global Action. The screen flow will create the Case record then a new screen flow page will pop up. I'm using Lightning component to call the screen flow. Below is the component and Controller for lightning component.

Any help will be appreciated.

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,event,helper) 
    {
         var flow = component.find("flowData");
         flow.startFlow("ScreenFlow");
    },
    
    /*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 === "ScreenFlow") 
       $A.get("e.force:closeQuickAction").fire();
    }
   }
  }       
})

1 Answer 1

1

You need to add the onstatuschange method to call controller method. Based on your requirement you can check status.

<lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}" />

In your handler method handleStatusChange you are checking status 'Next' which is not valid. You will get one of below status.

Valid statuses for a flow interview are:

  • STARTED: the interview successfully started.
  • PAUSED: the interview was successfully paused.
  • FINISHED: the interview for a flow with screens finished.
  • FINISHED_SCREEN: the interview for a flow without screens finished, and the component displayed a default screen with this message: “Your flow finished”
  • ERROR: something went wrong and the interview has failed.
    handleStatusChange : function (component, event) {
        if(event.getParam("status") === "FINISHED") {
            $A.get("e.force:closeQuickAction").fire();
        }
    } 

Reference :
https://developer.salesforce.com/docs/component-library/bundle/lightning:flow/documentation https://developer.salesforce.com/docs/component-library/bundle/force:closeQuickAction/documentation

1
  • Thanks A. K.! After making your suggestions and reading the info in the links I was able to get it to work! Sep 22, 2023 at 14:07

You must log in to answer this question.

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