Hello friends, today we will explore Step-by-Step Guide to Handling Selected Rows in Lightning Datatable with Salesforce Flow. Most awesome feature of Salesforce Flow is the ability to interact with Lightning Datatables. If you’re looking to capture user-selected rows from a Lightning Datatable in a Flow, you’ve come to the right place.
Getting selected rows from a Lightning Datatable in Salesforce Flow can greatly enhance your ability to interact with and process data based on user input.
Also chech this: Mastering Approval Processes in Salesforce with Apex
Overview
Lightning Datatable is a versatile component in Salesforce that displays data in a tabular format, allowing users to view and interact with records. In Flow, you can use Lightning Datatable to present data and let users select rows. Once rows are selected, you might want to use that data for further processing, such as updating records or triggering other actions.
Step-by-Step Guide
1. Create a Lightning Flow
Start by creating a new Flow in Salesforce:
- Navigate to Flow Builder:
- Go to
Setup
. - Search for
Flows
and selectFlows
. - Click
New Flow
.
- Go to
- Choose the Flow Type:
- Select
Screen Flow
for this example since you’ll be using a Lightning Datatable component that interacts with the user.
- Select
2. Add Get Record Element
We use Get Record Element for fetch Contact records so we can show them in Datatable.
3. Add a Lightning Datatable Component
To display a datatable in your Flow, you’ll use a Screen element:
- Drag a Screen Element onto the Flow Canvas:
- Click
+
and chooseScreen
.
- Click
- Add a Lightning Datatable to the Screen:
- Drag a
Data Table
component from the component palette onto the screen.
- Drag a
- Configure the Lightning Datatable:
- Set up the Data Table with the necessary fields. You’ll need to configure the
Table Data
andTable Columns
. - Define the columns to be displayed and ensure the
Data Table
is configured to allow row selection. - In Source Collection use Get Element variables so datatable will show the data.
- Set up the Data Table with the necessary fields. You’ll need to configure the
4. Configure the Data Table to Allow Row Selection
To enable row selection, you need to adjust the Data Table’s properties:
- Enable Row Selection:
- Set the
Selection
property toSingle
orMultiple
, depending on whether you want users to select one row or multiple rows.
- Set the
4. Display the Selected Rows
Once users select rows and submit the form, We display the selected rows in next screen and this is also datatable.
- Drag a Screen Element onto the Flow Canvas:
- Click
+
and chooseScreen
.
- Click
- Add a Lightning Datatable to th
- Drag a
Data Table
component from the component palette onto the screen. - Source Collection will be above screen data > Selected Rows
- Drag a