Loading

How to Navigate to a Record from a Screen Flow Using a Lightning Web Component Local Action

Data pubblicazione: Feb 6, 2026
Descrizione

Step 1: Create a Lightning Web Component

  1. create a new Lightning Web Component.

  2. Open the js-meta.xml file and configure it to be used as a Flow Action:

     
    <?xml version="1.0" encoding="UTF-8"?>
    <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
        <apiVersion>64.0</apiVersion>
        <isExposed>true</isExposed>
        <targets>
            <target>lightning__FlowAction</target>
        </targets>
        <targetConfigs>
            <targetConfig targets="lightning__FlowAction">
                <property name="accountId" type="String" label="Account Id"></property>
            </targetConfig>
        </targetConfigs>
    </LightningComponentBundle>

    Step 2: Add JavaScript Logic

    1. Open the .js file.

    2. Add the following code:

    import { LightningElement, api } from 'lwc';
    import { NavigationMixin } from 'lightning/navigation';

    export default class NavigationAction extends NavigationMixin(LightningElement) {
        // Input property to receive Account Id from Flow
        @api accountId;

        // Method executed when Flow invokes this Action
        @api invoke() {
            this[NavigationMixin.Navigate]({
                type: "standard__recordPage",
                attributes: {
                    recordId: this.accountId,
                    objectApiName: "Account",
                    actionName: "view",
                },
            });
        }
    }

     

    Step 3: Configure the Screen Flow

    1. Go to Setup → Flows → New Flow → Screen Flow.

    2. Add a Create Records element to create an Account record.

    3. From the Elements panel, add an Action.

      • Search for the Lightning Web Component (navigationAction).

      • Select it from the list.

    4. Pass the Account Id (from the record creation step) into the accountId property of the Action.

    5. Save and activate the Flow.

Numero articolo Knowledge

005135134

 
Caricamento
Salesforce Help | Article