Execute Flow

Overview

The Execute Flow interaction triggers a background process (an autolaunched Flow) from within a Dynamic Component. This is useful for automating tasks, updating records, performing calculations, or implementing any other logic in a Flow.

Important Note


How it Works

The Execute Flow interaction runs Salesforce automation silently in the background, without opening screens or interrupting the user.

Trigger & Data Injection

The process begins immediately when the user interacts with the component (e.g., clicking a button).

  • Trigger: The component initiates the autolaunched Flow.

  • Input Passing: Simultaneously, the component sends specific data (like a Record ID or Input Field Value) into the Flow's input variables to provide context.

Background Processing

The Flow executes its logic on the server side.

  • Execution: The Flow runs through its elements—creating records, performing complex calculations, or updating external systems.

  • No UI: Unlike Screen Flows, this happens entirely behind the scenes. The user stays on the current screen, and the interface remains responsive.

Completion & UI Update

Once the Flow finishes its logic:

  • Data Return (Output): The Flow sends results (e.g., a "Success" status or a calculated number) back to the component via output variables.

  • UI Response: The component acts on these results using "On Finish" actions. This is where you make the background work visible—by showing a Toast Notification, refreshing a Data Table, or navigating to a new page.


Configuration

Use these settings to connect your component to an Autolaunched Flow. This interaction runs background logic without opening any screens.

Flow Selection & Requirements

Define which specific automation logic to trigger by specifying the Flow API Name.

  • What it is: The unique identifier of the Flow you want to execute (e.g., Create_Case_Records).

  • Where to find it: Open your Flow in Salesforce Flow Builder and check the Flow Properties (the gear icon) to view and copy the API Name.

Critical Requirement

Input Variables (Passing Data)

Input variables act as parameters, allowing you to send context (like a Record ID) from your component into the Flow so it knows which data to process.

A. The Variable Name

Enter the exact API name of the input variable as defined in your Flow.

  • Requirement: The variable must be marked as "Available for Input" inside Salesforce Flow Builder.

  • Formatting: This field is case-sensitive. It must match the Flow variable exactly (e.g., recordId, accountName, opportunityStage).

B. The Value

Select the data you want to send into that variable. You can choose between two types of values:

  • Static Value: Enter a fixed value directly. Use this for data that never changes regardless of user interaction.

    • Examples: "Active", 100, true, "High Priority"

  • Dynamic Value (Mapped): Click the Map Icon to link the value to a dynamic source within your component. This allows the flow to react to the specific record or user selection. Common sources include:

    • Record Fields: Pass the ID or field value of the current record (e.g., Record: Id).

    • Component Attributes: Pass the state of another component (e.g., Datatable.SelectedRows).

Value Type
Description

Component Resource

Variables, queries, or formulas defined in your Dynamic Component

Component Attributes

Properties passed into your component

Global Variables

System-wide values like current user or organization info

Selected Row Data

Data from a selected row in a Data Table

Formulas

Calculated values or expressions

💡 Tip: Use the Mapped (x) icon whenever you need the value to be dynamic or come from your component's context. Use static values for constants that never change.


Output Variables

Optional

Output variables capture data that the Flow returns after it finishes running. This allows your Flow to send results back to your Dynamic Component—such as newly created record IDs, calculated values, or status messages—which you can then use to update the UI or trigger additional actions.

How output variables work:

  • Each output variable you configure maps to a corresponding variable in your Flow

  • The Flow variables must be marked as "Available for Output" in Flow Builder

  • The returned data is stored in a Dynamic Component resource that you specify

Configuring each output variable:

Name The exact API name of the output variable as defined in your Flow.

  • Must match precisely (case-sensitive)

  • Examples: outputContentDocumentId, calculatedDiscount, errorMessage

Resource Name The name of the Dynamic Component resource where the Flow's output will be stored.

  • This must be a variable you've already created in your Dynamic Component

  • The data type should match the type returned by the Flow (Text, Number, Boolean, Record, etc.).

Example mappings:

  • Flow outputs a Document ID → Store in: contentDocumentId (Text variable)

  • Flow outputs a discount amount → Store in: finalDiscount (Number variable)

  • Flow outputs success status → Store in: wasSuccessful (Boolean variable)

💡 Tip: Create your Dynamic Component variables before configuring the Execute Flow interaction, so they're available to select in the Resource Name field.


On Finish

The On Finish configuration defines what happens after the Flow completes successfully. This is where you create a responsive user experience by providing feedback, updating the interface, or triggering follow-up actions.


Step-by-Step Example

Bulk Update Contact Status

This example demonstrates how to create a header action button in a Data Table that updates the status of selected Contact records to "Active" using an autolaunched Flow.

Scenario

You have a Data Table in your Dynamic Component displaying Contact records. You want to add a "Set as Active" button in the Data Table's header actions. When users select one or more Contact rows and click this button, the selected Contacts' status should automatically be set to "Active" via an autolaunched Flow.

What you'll build:

  • A Data Table showing Contact records with selectable rows

  • A header action button labeled "Set as Active"

  • An autolaunched Flow that updates the Status field

  • An Execute Flow interaction that triggers when the button is clicked

1

Create the Autolaunched Flow

First, build the Flow that will handle the bulk status update in Salesforce

Flow Setup

  1. In Salesforce Setup, go to FlowsNew Flow

  2. Select Autolaunched Flow (No Trigger) and click Create

Flow Logic

The Flow needs three key components:

  1. Input Variable (Collection):

    • Name: ContactIds

    • Type: Text Collection (must allow multiple values)

    • Critical: This must be configured as a collection to receive multiple Contact IDs from the Data Table when users select multiple rows

    • This is what allows the Flow to process bulk updates rather than just a single record

  2. Update Records Element:

    • Find Contacts where: Id Is In {!ContactIds}

    • Update field: Status__c = "Active"

    • This updates all selected Contact records in bulk

Save and Activate:

  • Save the Flow with a descriptive name (e.g., Set_Contact_Status_Active)

  • Activate the Flow


The key principle: The Flow receives a collection of Contact IDs as input, finds all matching Contact records, and updates their Status field to "Active".

2

Configure Your Data Table in the Dynamic Component

Now that your Flow is created and activated, switch to configuring your Dynamic Component where the Data Table will display Contact records.

Where you are: In the Dynamic Component builder (not in Flow Builder anymore)

Set up your Data Table to display Contacts with row selection enabled:

  1. Select your Data Table component in the Dynamic Component

  2. Configure the data source and columns:

    • Ensure your Data Table is connected to a Query resource that retrieves Contact records

    • Add columns to the Data Table by selecting the fields you want to display (e.g., Name, Status__c, Email)

  3. Enable multiple row selection:

    • In the Data Table properties, locate the Max Row Selection attribute

    • Make sure it's not set to 1 to allow users to select multiple records on the Data Table

    • This ensures users can bulk update multiple Contacts at once.

3

Add the Header Action Button

Add the "Set as Active" button to your Data Table's header:

  1. With your Data Table selected, navigate to the Header section in the properties panel

  2. Click "Add Header Action"

  3. Configure the button:

    • Label: Set as Active

    • Icon (optional): utility:check

    • Type: Button

4

Configure the Execute Flow Interaction

Now connect the header action button to your autolaunched Flow so it triggers when clicked.

Where you are: Still in the Dynamic Component builder, now configuring the interaction

  1. Add the interaction:

    • In the Interactions panel, click "Add Interaction"

    • Interaction Type: Select Header Action Click

    • Target Name: Select the "Set as Active" header action button you created in Step 3

  2. Set the action type:

    • Type: Select Execute Flow

  3. Configure the Flow connection: Flow API Name:

    • Enter: Set_Contact_Status_Active

    • This must match exactly the API name of the autolaunched Flow you created in Step 1

  4. Pass the selected Contact IDs to the Flow: Flow Input Variables:

    • Click "Add Input Variable"

    • Name: ContactIds (must match exactly with your Flow's input variable name)

    • Value: Click the Mapped icon (🔗)

      • Navigate to your Data Table component

      • Select: {!DataTableComponentName.SelectedRowsKeyValue}

    • Important: Toggle on "Allow Multiple values (collection)"

      • This allows passing multiple selected Contact IDs from the Data Table to the Flow as a collection

      • Without this, only one Contact ID would be passed

  5. Configure what happens after the Flow completes: On Finish Actions:

    • Click "Add Item""Refresh All Queries"

    • This automatically reloads the Data Table to display the updated Status values after the Flow finishes.


What you've configured: When users click the "Set as Active" button, the Execute Flow interaction captures all selected Contact IDs from the Data Table, passes them as a collection to your Flow, and refreshes the table once the update is complete

5

Activate and test

Now that everything is configured, it's time to test your work:

  1. Save your Dynamic Component:

    • Click Save in the Dynamic Component builder to save all your changes

  2. Deploy to a Lightning page:

    • Navigate to a Lightning page where you want to use this functionality (e.g., a Contact list page or home page)

    • Edit the page and add your Dynamic Component to it

    • Save and Activate the page

  3. Test the functionality:

    • Go to the Lightning page where you added your component

    • Select one or more Contact rows by clicking the checkboxes

    • Click the "Set as Active" header button

    • Verify that:

      • The selected Contacts' Status updates to "Active"

      • The Data Table refreshes automatically to show the changes

      • You can select and update multiple Contacts at once


Important Considerations


In Summary

The Execute Flow interaction enables you to trigger autolaunched Flows directly from your Dynamic Components, creating powerful automation without requiring users to leave the page.

Key capabilities

  • Automate tasks in the background - Update records, perform calculations, or execute complex business logic when users interact with your component

  • Pass dynamic data to Flows - Send context-specific information like selected record IDs, user inputs, or field values through input variables

  • Handle results intelligently - Capture Flow outputs and use them to update your UI, display messages, or trigger follow-up actions

  • Create seamless experiences - Combine Execute Flow with actions like refreshing data, showing toast notifications, or navigating to different pages to keep users informed

Best practices

  • Always use autolaunched Flows (not Screen Flows) with this interaction

  • Ensure variable names match exactly between your Flow and the Execute Flow configuration

  • Use collections for input variables when working with multiple selected records

  • Configure On Finish and On Error actions to provide clear feedback to users

  • Test thoroughly with both single and multiple record selections

The Execute Flow interaction bridges the gap between user interface and automation, allowing you to build sophisticated, user-friendly applications that leverage the full power of Salesforce Flows

Last updated

Was this helpful?