Enhance your Flows with Data Tables – Part 3

Lightning Flow Screen Components are a great way to add power to and improve the look of your Flows.  In this four -part series, I’ll show you how a single component, designed to display a list or table, can enhance your Flows.

The unofficialsf.com website includes datatableFSC as one of many Flow Screen Components you can use for your own organization.

This component is derived from the datatable Lightning Base Component.  I recently enhanced the base component to be more powerful and Admin friendly.

I will be showing you some examples about how the Datatable component:

  • Can be used in place of a Record Choice Set (Dynamic Record Choice) for selecting a record while displaying more than a single field
  • Can be used to select multiple records from an object then perform additional actions on them
  • Can be used to present your data in an interactive and visually enhanced format
  • Can be used to display and inline edit a collection of records

Part 3: Displaying Tables in a Flow

How often have you had to use special formula fields or resort to building text output one line at a time in your flows to present a list of records?

In this post I’ll show you how to use the Lightning Datatable Flow Screen Component to turn this:

Into this:

I have an application where I wanted to use a Flow to display data from three separate objects on a single screen. In the original version of this Flow I created a text variable for each table and used a text template variable to insert each line into the table. Formatting was a challenge and alignment was impossible with this method.

Each table is created with a separate text variable.

The tables are built by appending a text template to the variable for each record.

The Text Template variable is used to append each of the tables fields together.

The final result includes all of the information, but it is not very easy to read.


In the new version of this Flow, I use 3 different Lightning Flow Screen Components (datatableFSC, horizontalRuleFSC, & navigationButtonFSC) from the unofficial.com website.

Other than a few Display Text sections, this screen is composed entirely of Lightning Flow Screen Components.

The horizontalRuleFSC components are used to add color and separation between my datatableFSC components and the navigationButtonFSC presents three custom buttons on the bottom of the screen.  The selected button determines what part of the Flow executes next.

The datatables are configured by providing the parameter values for the input and output sObject Collection Variables and each column is configured with parameters for field name, label and type along with optional parameters for alignment and width.

The final result gives me a Flow that I can use to view and interact with my tables.  I can sort any column in any table, I’ve added logic that allows me to select, then hide rows in any of the tables and I can select special processing to adjust the type of hierarchy used and then re-display the tables.

Here’s the Flow in action.

Youtube


See the complete series on how you can use the datatable Flow Screen Component in your Lightning Flows.

Part 1 – Use a Datatable to present a dynamic choice for record selection in a Flow.
Part 2 – Use a Datatable in a Flow to select and act on a collection of records.
Part 3 – Use a Datatable to display a formatted, interactive table in your Flow.
Part 4 – Use a Datatable to inline edit a group of records.




40 thoughts on “Enhance your Flows with Data Tables – Part 3

  1. Can this be used to display information that is not coming from a Salesforce object? What I want to do is display a list of addresses to choose from, but they are coming from different objects (from Account, Contact, and Case, as well as a custom object). I just want one list of addresses.

    Like

    1. This is a great component that has helped me perform actions way better than by using record choice sets, not to mention its great look and feel.

      Would there be an easy way to implement a search bar on top of the table? I’m considering it for cases where the amount of records will be much bigger than what one would normally consider user friendly.

      Like

      1. That sounds like a great future enhancement for this component. In the meantime, you could implement this in the flow by inputting a search value and doing a new Record Lookup to then pass a subset of records to the datatable component.

        Like

  2. Hi Eric, I’m using the table component in a flow and have a formula field of type text that includes a URL.

    I can get the field to display as a clickable link by setting the Type as URL but the text displayed is HTML and not the friendly display name set in the formula field. Here is the formula I’m using: hyperlink(“../s/profile/”&Id,FirstName&” “&LastName). Is there a way to update the component to show the URL friendly name (i.e. Firstname Lastname) instead of the HTML text – http://Jonny Utah?

    Like

  3. Hi Eric, I’m using the table component in a flow and have a formula field of type text that includes a URL.

    I can get the field to display as a clickable link by setting the Type as URL but the text displayed is HTML and not the friendly display name set in the formula field. Here is the formula I’m using: hyperlink(“../s/profile/”&Id,FirstName&” “&LastName). Is there a way to update the component to show the URL friendly name (i.e. Firstname Lastname) instead of the HTML text – http://Jonny Utah?

    Like

      1. Thanks Eric. Looking forward to seeing how this evolves. Already super impressed and thanks for making this available.

        Like

  4. Hi
    I have a trouble.
    My table shows a row by record but not the information. Every colums is blank.
    I change the component and the design as is mention in the instructions. I need to use PricebookEntry, so I specified this in the .cmp and the number of rows is correct but is blank

    Any idea?

    Like

      1. Thanks, it was missing a field.
        I have another question, can I Have input fields ? I need to be able to edit some data and save it in the same object

        Like

  5. Hi Eric,

    Thank you for this great component.

    I have an object called Authority Limits. It maintains a list of users and the various approval limits they possess. My goal is for users while in the Case object, to be able to invoke a flow that allows them to search for uses with the appropriate authority limits, displayed in a datatable.

    Once selected, I want the employee id from the Authority Limit record to be passed into a field in the current Case record called ApproverID. I have the datatable output to a record collection called varAuthorityLimitCol and the Single or Multi-Row Selection Set to 1. But I cannot figure out how to get the selected authority record id from the varAuthorityLimitCol to be able to “get it” and then update it. Is this possible?

    Like

  6. Add a different AuthorityLimit object collection variable to the Output section (You must manually assign your output variables). Even though that collection variable will only contain a single record, you will need to add a Loop in the flow to access the object record to get the recordId.

    Like

  7. Hi Eric. I have been wresting with adapting the code for a custom object Xenogenix_Invoice__c. I have been able to prelicate the functionality for a standard object but I keep getting the following error which I think is related to some incorrect editing oF the code in the developer console. ?

    Error message on save of the flow: An unexpected error occurred. Please include this ErrorId if you contact support: 163049448-559844 (1397861458)
    ANY ideas how I should fix this? Regards Mark

    Like

    1. Start by making sure this section of code is not commented out in the datatableFSCController.js file.

      if(cmp.get(‘v.mydata_custom1’) && cmp.get(‘v.mydata_custom1’).length > 0){
      cmp.set(‘v.mydata’, cmp.get(‘v.mydata_custom1’));
      cmp.set(‘v.obj’, ‘custom1’);
      cmp.set(‘v.preSelection’, cmp.get(‘v.selectedRows_custom1’));
      }
      if(cmp.get(‘v.mydata_custom2’) && cmp.get(‘v.mydata_custom2’).length > 0){
      cmp.set(‘v.mydata’, cmp.get(‘v.mydata_custom2’));
      cmp.set(‘v.obj’, ‘custom2’);
      cmp.set(‘v.preSelection’, cmp.get(‘v.selectedRows_custom2’));
      }

      Also, make sure you have system permissions to access each of the standard and custom objects listed in the code.

      Like

      1. I received a similar error code and eventually realized it was because the input collection variable was auto generated, not a manually assigned collection variable. Once I recreated the input collection as a manually assigned collection and updated the datatable input section, no more error codes!

        Like

    2. You’ll need to you use a custom collection variable as the input and output. I was getting the same error when using object collection variables created automatically by the flow (feature in Winter 20).

      Like

  8. Hi Eric, is it possible to use formulas that reference related field values in the component or do I need to create object fields to use? My use case is that I want to show Owner.name instead of OwnerId without having to create formula fields on my object.

    Like

  9. Hi Eric. Big fan of this component…been using it for a while now. Just came across and issue with date fields (that I havent experienced and or noticed before). When I display a date filed as type ‘text’ the date is correct, however, if I display as type ‘date’ the date is shown as one day in the past. Any idea whats going on here?

    Like

  10. Hi Eric, I’m getting strange behavior for the datatable component between Winter 20 and Spring 20. When I run the datatable component in Spring 20 using flow debug, the screen shows my fields and collection of opportunities. When running debug in Winter 20, only a line shows. No error, and the flow can continue, but non of the fields visible in Spring 20 are visible in the Winter 20 sandbox. Any idea what might be causing this issue?

    Like

    1. Yes, I’ve enabled manual variable output. If there are no records being selected, do I need to still assign an output collection variable?

      Like

  11. The component stores edited records in a different output collection variable than the output collection variable for the selected records.

    NOTE: The output attribute for selected records (Output Selected Accounts) is only used for identifying selected records in the datatable and may not contain the updated values. When you are combining editing and selecting in a single table, use the “Output Selected Accounts” attribute to get the list of selected records and their IDs and use the “Collection – Accounts” attribute to access the edited records.

    Like

  12. Great walkthrough and such a cool component! I had a few questions.

    1. Is it possible to reference relationship fields in the table? Contact.Account.Name for instance (maybe a bad example as I know just using the AccountId will create a clickable link)

    2. Can you help me understand how I could populate this table via an Invocable Apex Method?

    Thanks again!

    Chris

    Like

  13. Hi Eric,

    First of all, congratulations, the component is very cool, already implemented and it worked very well!

    Some questions, for exemplo, If I would want to formating a date like dd/MM/yyyy or dd/MM/yyyy HH:mm in the table, we have some way configurable?

    Another question is, in a formula field It’s possible to show a image, If I would want show this image in the table, we have some way configurable too?

    Thank you so much!

    Like

  14. Hi Eric,

    First of all, the component is amazing, I am using it in my sandbox and it is very useful. I just want to understand how can I display the rich text field in the way the data was stored. Do I need to mention the type?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s