In Automation, Flow, Wizard's Apprentice

Wizard Apprentice – Update Only User Selected Records From a Multi-Select List in Flow

One of the big frustrations people have with Flow is having users select records is a royal pain. There’s no “Lookup” field for a flow screen and searching for records can be messy and inconsistent. Unless you’re prepared to create a custom Lightning Component to embed into a Flow Screen, you’re almost out of luck.

There’s is a way if you’re able to provide a way to limit the possible records.

In this video, I show how you can provide a multi-select field displaying multiple records and then update only the records the user selects. It involves a few tricks and it works best when the potential list of records is small. In my example, the Flow is designed to list records related to a single account.

Pieces of the Flow

Here’s are the elements in the Flow:

  • Screen – With a multi-select for users to select records
  • Fast Lookup – To lookup the records the user might select
  • Loop – To loop through the sObject Collection from the Fast Lookup
  • Decision Element – Determine if the individual record being looped was selected
  • Screens – 1 to show a record not selected, 1 to ask for the user to input the value to update the selected record
  • Assignment – To assign the user input to the sObject Variable
  • Assignment – To add to a new sObject Collection for updating records
  • Fast Update – Update all the in the update sObject Collection

Behind the Scenes

  • Dynamic Choice – Contains list of records for users to choose from. These are the choices of the multi-select field on the first screen
  • variable: recordId – input variable to grab the ID of the record when used in a Flow Action
  • variable: vrAccountID – variable for the Account ID, default value is recordId
  • sObject Collection Variable: vrSoColAssets – Assets in the Fast Lookup. The records should mirror the records in the dynamic choice
  • Sobject Variable: vrSoAsset – A single asset record for the loop.
  • sObject Collection Variable: vrSoColUpdate – a collection variable to hold vrSoAssets that are going to be updated
  • Multi-Select Checkboxes Field: Select_Assets – this is the field on the first screen that uses the dynamic choice
  • variable: vrSelectedAssetsIDs – Text Variable which the value is Select_Assets
  • Outcome: Selected – This is from the decision element. To determine if a specific record was elected we check to see if vrSelectedAssetIDs contains vrSoAsset.id

 

Wizard Apprentice Flow Tutorial

How would you use this Flow trick? Do you know of a better way of accomplishing this without writing code? Let me know!

Want to see more videos on Flow? Let me know in the comments what you want to see!

Don’t miss a post! Sign up to receive email notications.

Subscribe

Subscribe to our mailing list

* indicates required
I want to receive email notifications about:

I run this site, the podcast, and my training videos for the community. I do incur some costs. I greatly appreciate if you can help me out by checking out my affiliates and – if you shop amazon – start your search on my site.

Recommended Posts
Showing 19 comments
  • Paula
    Reply

    Brian,

    I don’t know how you figured this out, but it’s brilliant! Thank you for posting this. I’ve spend hours and hours looking thru documentation, websites, videos etc. I was at the point of thinking is wouldn’t be possible. Even the official documentation states: “When the dynamic choice is used in a multi-select choice field, flow variables store the field values of only the last selected record in the dynamically generated set of choices.”

    Your’s is the only resource that I can find that actually solves this challenge. I would never have come up with this approach.

    • Brian Kwong
      Reply

      Paula,

      I”m glad you found the post and you found it useful. Thank you so much for the kind feedback.

  • Bob
    Reply

    Hello Brian,

    This is really cool! I’ve been looking for something like this forever. I tried recreated UPDATE ONLY USER SELECTED RECORDS FROM A MULTI-SELECT LIST IN FLOW, but It’s not working properly. It allows me to select check boxes but when i click next it just goes to the end of the flow. Do you have step by step instructions on how to recreate this flow? I’m trying to use it on opportunities with a custom object.

    • Brian Kwong
      Reply

      Bob,

      How much detail are you looking for? I have all the individual items listed in the post and the video walks through the flow as well.

      One thing I like to do when things aren’t going the way I expect them to is to add a screen for debugging at the various steps I’m concerned. You could add a screen after the fast update to see what your variables are set as. Other important places you can add some debug information is after each screen and assignment to make sure things are being set correctly. Putting one before the loop will also let you check to see if your fast lookup is pulling the records as expected.

  • Bob
    Reply

    Brian,

    When i run debug in from the flow designer the fast lookup receives the following message. I will try add screens for debugging to see what I get for information.

    FAST LOOKUP: Get_All_Products_from_Opportunity
    Find all Yushin_Product__c records where:
    Opportunity__c Equals {!varOpportunityId} (0063900000r08zy)
    Assign those records to {!scvYushinProducts}.
    Save these field values in the variable: Id, Price__c, Name
    Result
    Failed to find records.

    • Brian Kwong
      Reply

      How are you passing the opportunity Id into the flow? You could try using the 18 character ID. Also just double check that the opportunity has yushin products records and the running user has permission to view the object and record (I’m assuming your an Admin so you should see everything)

  • Bob
    Reply

    I have a custom lookup field on the yushin product object. So my fast lookup is Opportunity__c = varOpportunityId with data type = text, Input/Output Type = input and output and no default value.

    • Brian Kwong
      Reply

      How are you setting the value for varopportunityid?

  • Bob
    Reply

    Hi Brian I fixed fast lookup and I’m getting the check boxes now to select the product. I ran the debug and it gave me the following message and the flow also skips right to my last screen.

    DECISION: Is_Product_Selected
    Skipped this outcome because its conditions weren’t met: Selected
    Outcome conditions:
    {!vrSoProduct.Id} (a0618000004dYq9AAE) Contains {!drcgetprodrecords} (null)

  • Alexander
    Reply

    Hi Brian! Great video! I almost succeeded in making a similar flow. However I am experiencing one problem. I am not able to populate a text variable with the selected id’s from the choice. I also created a text variable and used the choice (a record choice set) as my default value but when debugging I notice that the variable remains null. Any advice? Thanks in advance!

  • Kari
    Reply

    Where did the resource come from for vrSelectedAssetsIDs? I didn’t see it created or referenced anywhere but that seems to be where the selected record IDs are being stored in the semicolon delimited format.

  • Kari
    Reply

    Nevermind…. I kept looping through the first half of the video trying to find it before you clearly explained later 😛

  • Joseph Piearson
    Reply

    This video has CHANGED MY LIFE. Thank you so much! Brilliant!

  • Ken S.
    Reply

    Hi this is EXACTLY what I’m looking for, thanks! But could you please demo the same using the current Lightning Flow builder? Having never used classic Flow Designer this is really difficult to follow, screens and process are almost totally different.

    • Brian Kwong
      Reply

      Unfortunately, I just don’t have time anymore to do lots of community projects. Work, family, self-care, and the pandemic is pretty much taking the time I have with a handful of exceptions for the podcast. When the new builder came out it was more followable but there’s been a lot of changes. Since I broke down the references in the post, here’s how things “translate” between the two. Pretty much everything is the same except Flow Builder now creates some of the variables. Variables are now a type of Resource. And Dynamic Choices are Record Choice Set type of Resource. The concept is essentially the same

      Here’s are the elements in the Flow:

      Screen – With a multi-select for users to select records: The Same Screen
      Fast Lookup – To lookup the records the user might select: Get Records
      Loop – To loop through the sObject Collection from the Fast Lookup: The Same Loop
      Decision Element – Determine if the individual record being looped was selected: The Same Decision
      Screens – 1 to show a record not selected, 1 to ask for the user to input the value to update the selected record: The Same Screen
      Assignment – To assign the user input to the sObject Variable: The Same Assignment. Sobject Variable is now a Resource Variable of Record
      Assignment – To add to a new sObject Collection for updating records: The Same Assignment. sObject Collection is the variable from your get Records
      Fast Update – Update all the in the update sObject Collection: Update Records
      Behind the Scenes

      Dynamic Choice – Contains list of records for users to choose from. These are the choices of the multi-select field on the first screen: Resource Record Choice Set
      variable: recordId – input variable to grab the ID of the record when used in a Flow Action: Resource Variable Text
      variable: vrAccountID – variable for the Account ID, default value is recorded: Resource Variable Text
      sObject Collection Variable: vrSoColAssets – Assets in the Fast Lookup. The records should mirror the records in the dynamic choice: Now the Record Resource created from your get Records
      Sobject Variable: vrSoAsset – A single asset record for the loop: Now this created by the loop
      sObject Collection Variable: vrSoColUpdate – a collection variable to hold vrSoAssets that are going to be updated: New Resource, variable, Record, Allow multiple values checked. You need to create this one since it’s not coming from a get records.
      Multi-Select Checkboxes Field: Select_Assets – this is the field on the first screen that uses the dynamic choice: Same but it uses the Resource Record Choice Set
      variable: vrSelectedAssetsIDs – Text Variable which the value is Select_Assets: New Resource Variable, Text
      Outcome: Selected – This is from the decision element. To determine if a specific record was elected we check to see if vrSelectedAssetIDs contains vrSoAsset.id: The same, Outcome is from a Decision

  • Ken S.
    Reply

    It would also help if you could capture in higher res and use slightly more descriptive / differential display names for the variables, so we could see the names clearly and remember the names more easily to make the associations…they are all named so similarly and it’s almost impossible to remember or tell one variable from the next. This is where the new Flow builder really sucks when you’re trying to figure out “where you are”…with every single screen looking almost exactly the same and then variables, collections, record sets etc almost all having the same names except for a letter or two and all the dialog boxes looking nearly identical… :-\

    • Brian Kwong
      Reply

      I’m pretty much limited to the resolution that I have available to me. I record at 1080p and upload it at that resolution. That’s the best that I’m able to do with the resources I have.

  • Ken S.
    Reply

    Thanks a lot, Brian. My use case was a bit more complex as I needed to first clone the original custom object record + its related asset (in my case, a Finance object line and related Expense object line), then prompt for user modifications to only certain cloned related Expense lines that are created on the new Finance line, while leaving the original intact.

    This is was a bit more complex because to copy records and modify only some of their fields in the “cloned” copy, you’re stuck manually mapping every single field (100+ in our custom object). The workaround is to use a subflow and instead pass the original record with all its related fields to the subflow, then return to the parent flow to do the rest. This works beautifully!

    I was actually able to get my flow working through a combination of your methods + implementing the above thanks to an amazing article I found here (https://admin.salesforce.com/blog/2020/duplicate-a-record-with-lightning-flow-in-spring-20). I created 2 subflows, one to clone the Finance line, then another to clone the related Expense lines. It prompts the user which Expense line(s) to modify in the cloned copy, then invokes the Expense line subflow as part of the loop, rather than a 2nd assignment to a new record collection as you did above to create a new collection of just the records to update.

    Your article was definitely a huge help! Perhaps I can get my Lightning Flow posted somewhere time permitting to help others as well. (BTW turns out the low-res font was due to my connection, so my bad…although a bit small, things were much more legible once I got onto my regular home wifi.) Thanks a lot and stay well!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.