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
Hi this is amazing, just 2 points, is this support inline edit? and is this support both row level action and multi select action ? Thanks.
Hello,
Currently, the in-line edit is not supported we are working on that part. There are some basic actions supported like display the record and delete the record.
Good article!
Hey, Thanks Amit for this amazing articles. Just wondering about one point: is the selected records get lost over pagination ? If we select records from differents pages, just the selected record from the last page is retrieved.
The selected records gets lost. You need to implement custom code in order to persist those records.
Hello,
Great component 😉
When I added custom field and not standard field on case, nothing appeared, why?
How are you passing the fields?
Hello SFDC Panther, thanks for the component.
However, I have the same problem as Claire : when I insert custom fields, nothing is showing in the header.
I have made the fix and uploaded the fixed version long back. Please make sure you have installed the latest version
Hi, The same problem I am also getting and not able to see the custom fields in that. Can you please share the link of the updated version that you are talking about then we can try using that? If I add the custom fields then the flow is not coming on the screen.
Can you try below package and let me know if this works?
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0o000003bSZq
Hi Amit, thanks for sharing the post !!
I’m not able to find the latest version (fix for custom fields), can you pls guide me with the latest version download pls.
Can you try below package and let me know if this works?
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t0o000003bSZq