Use LWC in Flow Salesforce Part -2

by Rijwan Mohmmed

Hello friends, today we are going to discuss Use LWC in Flow Salesforce Part -2. By embedding LWC in Flow, Lightning Web Components brings a whole new level of interactivity and customization to your Flow screens, enabling you to create more engaging and user-friendly experiences. We can pass data to each other in FLOW and LWC.

In this blog, we will pass data from LWC to FLOW.

Also, check this: Use LWC in Flow Salesforce Part 1

Key Highlights :

  1. User-Centric: LWCs allow you to design Flow screens that match your exact needs and user preferences.
  2. Interactivity: You can build components with advanced functionalities, like data validation, dynamic calculations, or interactive forms.
  3. Customization: LWCs can be tailored to fit your brand and style, providing a seamless user experience.
  4. Dynamic Forms: Create forms with custom validations and interactive elements.
  5. Guided User Journeys: Use LWCs to guide users through complex processes.
  6. Data Visualization: Display data in visually engaging ways.
  7. We will send data from LWC to flow variables.
  8. We used import {FlowAttributeChangeEvent, FlowNavigationNextEvent} from ‘lightning/flowSupport’ for send data from LWC to flow.
  9. By using LWC in flow we can created custom type datatable in flow, that is more customised.

Code :

1. Create an LWC that complements your Flow’s purpose, whether it’s capturing data, displaying information, or performing calculations. Here we import flow action to handle flow button. We configure xml file to send data.


	<lightning-card title="Use LWC in Flow Salesforce Part - 2 (Pass data LWC to Flow)" icon-name="custom:custom14">
		<div class="slds-m-around_medium">
			<lightning-input label="Name" type="text" name="name" value={name} onchange={handleChange}>
			<lightning-input label="Email" type="email" name="email" value={email} onchange={handleChange}>
			<lightning-input label="Phone" type="phone" name="phone" value={phone} onchange={handleChange}>
			<lightning-button label="Navigate to Next" variant="brand" onclick={handleNext}></lightning-button>


import { LightningElement, api } from 'lwc';
import {FlowAttributeChangeEvent, FlowNavigationNextEvent} from 'lightning/flowSupport';
export default class EmbedLWC2 extends LightningElement {
    @api name;
    @api phone;
    @api email;
    handleChange(event) {
        let fieldName =;
        if (fieldName == 'name') {
            this.dispatchEvent(new FlowAttributeChangeEvent('name',;
        } else if (fieldName == 'email') {
            this.dispatchEvent(new FlowAttributeChangeEvent('email',;
        } else if (fieldName == 'phone') {
            this.dispatchEvent(new FlowAttributeChangeEvent('phone',;
     //Go to Next screen of Flow
       const nextNavigationEvent = new FlowNavigationNextEvent();


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" fqn="lwc_TextBox">
        <targetConfig targets="lightning__FlowScreen">
            <property name="name" type="String" role="outputOnly"/> 
			<property name="phone" type="String" role="outputOnly"/> 
			<property name="email" type="String" role="outputOnly"/>

2. Add the LWC to your Flow screen, simply by dragging and dropping it onto your canvas. Here we create 3 text type fields, which are name, email, and phone. After this, we will drag and drop our LWC component which we already created. When you click this LWC component, open manually assign variables section, 3 fields show on the right side. We will put flow variables in these so the LWC field value assigned to them when we change Lwc field values.

Output :

Reference :

  1. LWC attributes for Flow
  2. Using LWC in Flow
What’s your Reaction?

You may also like


Milesh October 15, 2023 - 4:30 pm

Dear Raijwan,
I have one question, if the values are being assigned manually to the variables then what is the use of this.dispatchEvent(new FlowAttributeChangeEvent(”,”)) ?

I commented these lines and tried I am still able to get the values on the output screen.

Rijwan Mohmmed October 16, 2023 - 5:27 am

This is used when we update flow variables with going next screen.


Leave a Comment