Loading

Salesforce Platform Flow: Select Multiple Records with Data Table Component

Date de publication: Sep 22, 2026
Description

Key Definitions

  • Screen Flow (user-interactive automation)
  • Data Table (component for displaying and selecting records)

Business Scenario

A business has a data model in which an Account can have multiple related Financial Records. Cases can also be related to Financial Records using a junction object to support a many-to-many relationship. A user should be able to utilize a screen flow embedded on a Case record page to select from the Account's related Financial Records. A Case Financial Record should then be created for each of the selected records in the data table. The entity relationship for this data model is outlined below:

Entity relationship diagram showing Account, Financial Record, Case, and Case Financial Record junction object

Résolution

Solution Overview

We can use a screen Flow with a Data Table component to display the Case's Account's related Financial Records, allowing the user to choose which records to relate to the current Case. The screen Flow can be embedded directly on the Case record page to allow for ease of use. As a best practice, be sure to build and test Flows in a Sandbox before deploying to a Production environment.

Step-by-Step Configuration

Step 1: Open Flows in Setup

From Setup, navigate to the Home tab. In the Quick Find search box, search for Flows. Click on Flows to navigate to the Flow setup page.

Flows setup page in Quick Find

Step 2: Create a new Screen Flow

Select New Flow from the top right side of the page. A new window will open - select Screen Flow, then click the Create button.

Selecting Screen Flow type when creating a new flow

Step 3: Create the recordId variable

The Flow Canvas is now open. From here, we will configure the Flow logic necessary to display the Case's Account's related Financial Records, allow the user to choose a set of records, and ultimately create Case Financial Records for the current Case. Before we start with the Flow logic, we first need to create a recordId variable to store the value of the Case and all its fields. We will use this variable to capture the source Case record and its field values so that we can easily use this information in the Flow.

  • Expand the Flow Toolbox at the top left of the canvas.

Flow Toolbox expanded

  • Click on New Resource.

New Resource menu option

  • Create a Variable and set the API Name to recordId - it's important for this to match exactly.
  • Set the Data Type to Record, the Object to Case, and select Available for Input.

recordId variable configuration set to Case object

Step 4: Get the Account's Financial Records

Add a Get Records element to the canvas - we will configure this to find Financial Records for the Case's related Account.

Get Records element added to canvas

  • Provide a Label and Description for the element.
  • Set the criteria to find Financial Records where the Account__c is the same as the Case's Account record - this is stored in our recordId variable as {!recordId.AccountId}.
  • Set the element to find All Records, and leave the option enabled for Automatically store all fields.

Get Records criteria configuration for Financial Records

Step 5: Add a decision for whether records were found

Add a Decision element to the canvas - we will use this to determine if any Financial Records were found related to the Case's Account.

Decision element added to canvas

  • Provide a Label and Description.
  • Label the first Outcome tab and check that the output of the previous Get element {!Get_Financial_Records_for_Account} has a value - use Is Null {!$GlobalConstant.False}.
  • Leave the Default Outcome as-is.

Decision outcome condition configuration

Step 6: Handle the no-records-found path

Add a Screen element for the Default Outcome path - we will display a message letting the user know that the Account has no related Financial Records. (If you wish to add more logic here, such as giving the user the ability to add Financial Records, this could be configured, but will not be covered in this tutorial.)

Screen element for no records found path

  • Provide a Label and Description for the Screen element.

Screen element label and description fields

  • Add a Display Text component to the screen - you can find this along the left sidebar in the Components tab - configure a message to let the user know no Financial Records were found.

Display Text component configuration

Optional: customize this path further to add additional functionality - for this example, the Flow will be set to End if this path is taken.

Flow set to end on the no records found path

Step 7: Display Financial Records in a Data Table

Add a Screen element for the Decision Path which found related Financial Records - we will use this screen to display those records in a Data Table and allow the user to select which records to associate with the Case.

Screen element for the found records path

  • Provide a Label and Description for the Screen element.

Screen element label and description

  • Add a Data Table component to the screen - provide the API Name and Label. You may optionally select to use the Label as the Title for the table.
  • Choose {!Get_Financial_Records_for_Account} for the Source Collection - this will contain the Financial Records found via the previous Get Records element.

Data Table component source collection configuration

  • Configure the Rows to allow for Multiple Selection - optionally define a minimum and maximum number of records which can be selected. A default selection can also be defined, if desired - this will pre-select records for the user. A minimum of 1 will be used for this example to ensure the user must select at least one record.

Data Table row selection configuration

  • Configure Columns to provide the desired fields to display from the Financial Records on the Data Table - for this example, we select Account Type, Account Number, and Account Balance.

Data Table columns configuration Data Table preview with configured columns

Step 8: Loop through selected rows

Add a Loop element to the canvas. Give the element a Label and Description. This element will loop through each of the records selected by the user in the Data Table.

Loop element added to canvas

  • Select the Data Table's Selected Rows as the Collection variable to iterate through - {!datatable_AccountFinancialRecords.selectedRows} - this will contain the records selected by the user.

Loop collection set to Data Table selected rows

Step 9: Assign values to a Case Financial Record variable

Add an Assignment element to the canvas - this will be used to assign values for the Case Financial Records (the junction object) to create for each of the selected Financial Records.

Assignment element added inside loop

  • Provide a Label and Description.

Assignment element label and description

  • When selecting a variable, add a New Resource - select Variable as the Resource Type, and select Record as the Data Type. Select Case Financial Record as the Object, and select Available for Input. New variable resource for Case Financial Record
  • Set the value of {!var_CaseFinancialRecord.Case__c} to {!recordId.Id} - this sets the Case__c value for the junction record to the value of the current Case.

Assignment setting Case__c to current Case Id

  • Set the value of {!var_CaseFinancialRecord.Financial_Record__c} to {!Loop_Selected_Financial_Records.Id} - this sets the Financial_Record__c value to the value of the currently looped Financial Record.

Assignment setting Financial_Record__c to looped record Id

Step 10: Add the record to a collection variable

Add another Assignment element to the canvas - this will be used to add the previously assigned Case Financial Record values to a collection. Provide a Label and Description.

Second assignment element added to canvas Second assignment element label and description

  • As in the previous step, add a New Resource directly from the variable selection. Similarly, select Variable as the Resource Type, and select Record as the Data Type. Select Case Financial Record as the Object, and select Available for Input. Be sure to check the box for Allow multiple values (collection).

Collection variable resource configuration

  • Select {!var_CaseFinancialRecordCollection} and Add the entire variable {!var_CaseFinancialRecord} to the collection.

Assignment adding record to collection variable

Step 11: Create the Case Financial Records

Outside of the Loop, add a Create Records element - select to create multiple records and select {!var_CaseFinancialRecordCollection} as the records to create. (As a best practice, a Fault Path should also be specified in the event the Create element fails - this is not covered in this tutorial.)

Create Records element added outside the loop Create Records configured to create multiple records

Step 12: Confirm success to the user

Add a final Screen element to serve as confirmation that the records were created successfully.

Final confirmation screen element added Confirmation screen message configuration

Step 13: Review, debug, and test the Flow

Review, debug, and test the Flow results - the completed Flow may look something like this:

Completed flow canvas overview

Step 14: Activate and embed the Flow on the Case page

Activate the Flow and embed it on a Case record page. To embed the Flow on a Case record page, navigate to a Case record, and select Edit Page from the Setup icon dropdown menu.

Edit Page option from Setup dropdown on Case record

  • Drag the Flow component to the desired location on the page.
  • Select the Flow to run from the component - this should be the name of the Flow we created throughout this tutorial.
  • Be sure to select the option to Pass all field values from the record into this Flow Variable for the recordId variable - this ensures the Case record is passed to the Flow to provide context for the Flow logic.

Flow component added to Case Lightning page with recordId mapped

  • Be sure to Save and Activate the page, if needed - navigating back to the record page should display the Screen Flow with the needed context.

Case record page showing embedded screen flow

  • Here's the results of the Flow when selecting two financial records from the Data Table:

Data Table with two financial records selected Confirmation screen after creating case financial records Created Case Financial Records related list on the Case

Notes

  • As a best practice, always be sure to build and test your Flow in a sandbox.
  • Additional enhancements can be made to this Flow by checking to see if Case Financial Records exist prior to displaying them in the Data Table - this ensures existing records are not available for selection.
  • The Embedded Flow Component could also be set to conditionally display based on certain Case record data (for example, only show the component when the Case has a value for AccountId).
  • All data used in this example is entirely fictional.
  • This tutorial is based on this post in the Trailblazer Community.

Written by: Zack Terry | Salesforce Answers Leader
Zack Terry is a Senior Salesforce Solution Architect at Fast Slow Motion, which aims to be a blessing to business leaders by helping them implement and maximize their use of the Salesforce platform. At the time of writing, Zack has worked in the Salesforce ecosystem for nearly a decade, holds 20 Salesforce Credentials, and has achieved the rank of "All-Star Ranger" on Trailhead. He regularly participates as an Answers Leader in the Salesforce Trailblazer Community.

Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials"). Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality, usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a "best" answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions.

If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed

Numéro d’article de la base de connaissances

000925354

 
Chargement
Salesforce Help | Article