How to use both the Selected and the Edited records in a Datatable

See an updated version of this post here: Let’s Revisit How to use both the Selected and the Edited records in a Datatable

My Datatable Flow Screen Component allows a user to both Select records and make Edits to records.  The component returns two separate collection variables.  One of them includes the original values of just the selected records.  The other one includes just the edited records whether they were selected or not.

Sometimes, you may want to process just the selected records in your flow, but include the edited values in those selected records.  This sample flow shows how you can create a selected record collection with edits.  The flow loops through each of the selected records and if no edits were made to it, it gets added to the final collection.  If an edited version of the record is available, it gets added to the final collection instead.

Here’s the Select & Edit Screen Datatable displaying all of the Product records from an Opportunity.

I’ll select 3 records and make edits to 2 of them.

My final results show the 3 selected records with the edited fields included.

Let’s go through the steps you can follow to combine the outputs from the Datatable component. In this section, I’ll show you how each of the nodes in the flow is configured.

I start with an Opportunity record with an Id that is passed into the flow.  Whenever possible, let the flow Automatically store all field values.

All of the Opportunity Products are added to a Collection (OpportunityLineItem).

Because I am displaying a similar Datatable multiple times in this flow, I store my attributes in variables so they can be reused for each Datatable.

The Datatable is displayed using the attributes assigned earlier.  Here, the user can select and edit records.

I am manually assigning the outputs from the Datatable to new collection variables to make the steps in this flow more readable.

This loop will take us through each of the records in the collection of Selected records where we will perform the next few steps on each record.  New in Summer ‘20, the flow will automatically create a loop variable for you.

In this step, I look for a record in the collection of Edited records with the same Id as the current Selected record in the loop.  The “Find Records In Collection” Flow Action is part of a group of very powerful actions you can include in your flows to act on record collections.  The entire group can be found and installed from here.

The output from the Flow Action will be the matching record from the collection of Edited records if found, otherwise it will return a null value.  This Decision checks to see if that record was found.

When an Edited record is found, it is added to the final collection variable that we will be using for the rest of our flow.

When there is no matching Edited record, we use the Selected record from the Loop instead.

Whichever record we chose now gets added to the final collection variable.

After the end of the Loop, I display another Datatable with the values from the final collection variable.  This is just an example.  In your own flow you may be doing something here like adding updated products to a new renewal Opportunity or something else with the selected and edited records.



Collection Actions for Flow

Sample Flow (Install in Sandbox)
This includes DatatableV2 and FindRecordsInCollection

50 thoughts on “How to use both the Selected and the Edited records in a Datatable

  1. Hi Eric – Very nice utility.

    In this example you’re demoing update existing records.

    We’ve requirement to update and/or ADD new opportunity product records using flow.

    Can we add new opportunity product record using this utility?


  2. Hi Eric,

    thumbs up for your datatable v2. I just have one question: What is the best way to integrate your component into my Salesforce DX project?

    Using git clone and then copy your source code into my project?

    Deploy to my Dev Org, create an unmanaged package and then use sfdx force:package:install on my scratch orgs?

    Nevertheless, great work and thanks!


  3. Hi Eric,

    Thanks for an amazing component. I am trying to use the “Pre-Selected Rows” but having a hard time getting it to work. Here is my use case:
    I am using datableV2 to load records from a custom setting and have the user select one (or more) records for the next step in the flow. This is working perfectly. I also need to have one record to be pre-selected. So I added a “Get Records” element and filtered the returned rows to the one that I want. The other options in that “Get Records” are: All records, Automatically store all fields. I am using that in the datable V2 “Pre-Selected Rows”. But I still can’t get the row to be pre-selected. Am I doing this the right way? thanks!


      1. As per your suggestion, I changed it to a manually created variables and it is working now. Thanks for your help!


      1. Perhaps. The ideal would be if I could have the error message pop up on the screen after the Participating Individuals and Room is chosen, if they exceed the room capacity for total guests with that room reserved during the room’s dates. I posted a bit more about it here: Thanks in advance for your help with this, Eric. Much appreciated.


  4. Hello Eric,

    First of all, many thanks for this component which is very powerful.
    I get an issue to edit fields of type number.
    My SF field is numeric (16,2). When I want to edit it in the table, it works when I enter 10,00 but it doesn’t work when I entered 10,01 (or 10.01). I click on Next and I am back to the table and again and again.
    You mention percent field cannot accept digits at the right of the comma but I have not read anything concerning decimal ?
    Tank you for your help and once again, Bravo !
    And Happy new year 2021


    1. I’m still unable to reproduce this behavior. Can you proivde some more detail about how you have configured the datatable and if this happens on both currency and numeric fields?


  5. Hello Eric,
    it’s working now on API version 51.
    Unfortunately, my Prod is on 50, I will wait the next version.
    Thank you


  6. Eric, this is a great tool – i have used it a ton, and love the improvements you continue to make to it.
    I do have a question – is there a way to determine the newly selected rows and only action on them? For instance i have an opportunity with line items preselected. in the flow, the datatable is pre-selected with the line items that were already chosen, but the user wants to add more line items to the opportunity. if i do this currently, i am either creating duplicates of the line items already selected (if i use the selected items collection) or i can only capture the edited line items (but not line items that were added, but not edited).
    I guess what i am looking for is if a change to the “selected” column could indicate an edit, just like a change to any other column….


  7. Hi Eric,

    Can you have a loop element immediately after the datatable screen? I created a manually assigned variable for “Output Edited Rows” but am getting ambiguous errors when I try to use it in a loop right away.

    Datatable Version: 3.0.10
    Example error: “Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. Error ID: 1074418025-4895 (2127287436)”

    Thanks for the great tool!


    1. Yes, you can loop through either the Edited Rows or Selected Rows collections immediately after the Datatable screen. You could try adding a decision first to see if the collection is empty.


  8. Many thanks for your speedy reply. That, along with some other tweaks, seems to have moved us past the ambiguous error.

    Now have a question about entering percentages into the datatable:

    Is it a limitation of a Lightning Input field that a user can not enter “40” and have it reflect as “40%” (as a user can do in a standard Salesforce field)? Are there any workarounds for this that you know of?


  9. Hi Eric,

    Thanks again for this amazing tool. For some reason I’m unable to assign the variables (Edited and selected). It seems that “Edited” is not available. Am I missing something?


  10. You can forget y previous comment. I just figured it out. I was literally creating a collection for the wrong object (the objects I’m working with have a similar name). Thanks again

    Liked by 1 person

  11. Super nice component! I ran into an issue and am not sure what I am doing wrong. Essentially, I want to update the status of a selected record in the table.

    Currently, I am looping over the selection collection and then assigning the new status value to the status field of the current item in loop but somehow the records don’t really update when I subsequently use the Update Records element?


    1. If you are going to modify values in a record collection in a loop, I recommend that you don’t try to modify the loop collection variable. Make your changes to a record in the loop and then add that changed record to a new collection that you will pass to a Record Update after the loop.


  12. Hi Eric, I’m really excited to try some of this. I have installed datatable in both sandbox and production and in both cases am having issues with the “configure column” button. I get stuck with spinning dots and a “please wait…loading field details.” Any ideas to nudge me in the right direction? Thanks for putting this together and maintaining it.


      1. Thanks, it was the clickjack protection that was leading to the error. Appreciate your response!


  13. Pingback: ericsplayground
  14. I’ve had this deployed for a while but am now getting an error on any Read Only field: ‘Apex Action error: Field GrandTotal is not editable’ during the display at runtime and Configure Columns screen then the table doesn’t populate. Not seeing anything in the troubleshooting that applies.


  15. Hi Eric, after the user edit values on the table, on the next step, the {!OpportunityProducts.outputEditedRows} is empty. I’m I missing something? I tried to manually assign to a new collection variable but it didn’t work. I’m using the OpportunityLineItem object. I’m using v 3.3



  16. Is there any road map to support validating the edited values in dataTable and making the particular field column as required?.

    Example: Current validation for Email is only checking if it contains ‘@’ and not for the valid format.


    1. The email validation you are referring to is the standard validation handled by Salesforce when editing an email field. It is not any alternate validation provided by the datatable component. Making a column entry required is a bit more complex and should be handled by the flow after the datatable screen. Are you looking to make just a single edit required in a column, all rows must contain a value, or something else? You can always display a message and navigate back to the datatable screen if your custom validation checking shows any exceptions.


  17. Hello –

    The Datatable Configuration Wizard doesn’t load for me and keeps spinning. I am in Sandbox as well. Am I missing a component or something?


    1. If you see this error when trying to Configure Columns, try going to Setup > Security > Session Settings and unchecking “Enable clickjack protection for customer Visualforce pages with headers disabled“. Also, in your Setup > User settings, make sure both Debug Mode and Development Mode are Unchecked.


  18. Hi Eric,
    I am trying to use Datatable in my flow to show all Facilities related to a Billing Group. But I want all facility records to show up as “Selected”. So I want all the boxes to the set to true. I can’t find the way to do that. Can you guide me through if this is possible through this component. Thanks.


Leave a Reply

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

You are commenting using your 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