Hello #Trailblazers,
Welcome back to SFDCPanther and wish you a very happy new year 2022.
In this blog post, we will learn how to develop a lightning datatable for Salesforce Lightning Flow Builder.
We know that we can not directly develop the Lightning DataTable for Salesforce flow. So I have developed a lightning web component that can be used inside a flow and will work dynamically for any object.
The Lightning DataTable has the below features which can be developed for any flow
Display List of Records for Any object with the mentioned fields.
Ability to make the fields HyperLink
You can also select max no of records in flow and get the selected records back to flow
You can filter the records based on parent record
Pagination to display the records
OUTCOME OF THE FLOW
INSTALLATION
You can install the package in your org from the following links
For Production or Developer Org – https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0o000003bSZl
For Sandbox Org – https://test.salesforce.com/packaging/installPackage.apexp?p0=04t0o000003bSZl
STEPS TO CONFIGURE THE DATATABLE
After installing the package. You need to create a screen flow where you can use a data table.
Go to Setup
From Quick Search box search for Flows
Select Flows under Process Automation
Click on New Flow
Select Screen Flow from the Popup
Click on + icon and Select Screen
From Components Tab Search for DataTable Component
From the right hand side Select the Object under which you wanted to create the datatable
Provide the values for the no of records you wanted to query, no of records to display on table, and the maximum no of records to be selected from the data table
Scroll down to below a little bit and provide the necessary values for the other required fields
Table header fields – All the fields which you wanted to display in datatable comma separated. For Example – CaseNumber, Subject, Account.Name, ContactId
The Object API Name to display the records – It will be auto populated from the object you selected in first step.
The Sort Direction – How you wanted to sort the records. Valid values are DESC and ASC
Display Link – The list of comma separate fields where you wanted to put the hyper link
Field API Name to Filter the Records – The Field API name on the Query object by which you wanted to filter. For Example Contact Id
Id to Filter the Records – The value by which you wanted to filter the records.
Save and debug the flow
As you can see we have got all the case records within the pagination.
Now, if you want to get the selected record information. You can use the below variable
firstSelectedRecord – This variable will give you the first selected record
allSelectedRecords – This variable will give you all the selected records if you have selected multiple records
Below is an additional screen which I have added to display the selected case record Case Number
Below is the screen where we have selected one case record
And below is the screenshot for the selected record.
FINAL OUTCOME
Thanks for reading 🙂
Please let us know your thoughts in the comment section