7

Is there a way in LWC, to call flow from web components. I have a task where I need to add flow into Global action traditionally its not possible with salesforce out-of-box functionality. I'm able to do it via aura component. I wanted to know if there is a way to implement it in LWC.

1 Answer 1

9

You can embed a flow in LWC using the new lightning-flow component (from Winter '23 platform release).

To embed a flow simply use the below:

 <lightning-flow flow-api-name="flow_api_name"
                            flow-input-variables={inputVariables}
                            onstatuschange={handleStatusChange}
                        >
 </lightning-flow>

Here flow_api_name is assumed to be the API name of the flow. Note this can be dynamic and you can pass this via JavaScript controller.

flow-input-variables is where you can pass in input variables from lwc to the Flow. You will need a function like below in the JavaScript controller

get inputVariables() {
    return [
        {
            name: "recordId",
            type: "String",
            value: this.recordId
        }
    ];
}

onstatuschange is how you can handle the status changes in flow including flow finish behavior.

handleStatusChange(event) {
    if (event.detail.status === "FINISHED") {
       
    }
}
5
  • Question was the other way around.....
    – user61140
    Commented Jun 21, 2020 at 7:53
  • For global action override one could just use flows and flows can have lwc in them. The other workaround is use aura as it allows both Commented Jun 21, 2020 at 12:46
  • For a possible workaround, check out this: unofficialsf.com/… Commented Feb 12, 2022 at 0:03
  • 1
    This now wants to be updated to cover the Winter '23 lightning-flow feature.
    – Phil W
    Commented Aug 18, 2022 at 15:11
  • Yes I have in my backlog to update few of answers! Embedding flows in LWC is an exciting update! We are thrilled about how one could do dependency injection with it. Commented Aug 18, 2022 at 15:17

You must log in to answer this question.

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