Flows | Use Flows to Bulk Update Records from List View in Salesforce

How to use Screen Flow as a List View Button to Edit Multiple Records at once in Salesforce? In this post we will see how to use a Screen Flow in a List view in Salesforce. There are many use cases where you need to perform some custom action on multiple records in a List View in Salesforce. We will see how to create a custom List View Button using a Screen Flow in Salesforce to perform actions on multiple selected records at once. We will see how to Pass Selected Records from a List View to a Flow. Based on these passed records from List View to a Screen Flow, we will just use the Flow to do perform desired business logic.

Create a List View Button using a Screen Flow 

Let's see how to create a List View Button to invoke a Screen Flow in Salesforce. We will use a complete declarative approach to achieve this which means:


  • No coding. 

  • No custom components.

  • Only standard Flow features.

  • Only declarative, standard salesforce tool available on all editions (including Essentials)

  • Future-proof and rock solid.


In this article, you will learn how to Pass Selected Records from List View to a Salesforce Flow.


Requirement - Flow List View Button - Declarative tools only

A while ago, I came across a very weird requirement from my customer. We had to create a system, which would get fully dependent on no-coding tools. They wanted to make a PoC (Proof of Concept) for their larger implementation team. 


They were doing this because some of their departments had to be administered by independent teams, and they wanted to make the system easier to maintain. 


One of the user stories involved Bulk Updates of the Account records. It was a pretty sophisticated algorithm pulling many related records and doing some serious things. When I first saw the requirement, I immediately pointed out that this is impossible without creating a custom component. Still, the PO of the project gave me one day to do my research and find a workable solution that would use only DECLARATIVE tools. No coding. No custom components. Stuff that could be done by an administrator without extensive Salesforce knowledge. And I found one working method, worth sharing with you.


In a nutshell, here’s what we are going to do:

  • Create a Screen Flow with a special type of input variable, “ids”

  • Create List Button using old good List Buttons (not global actions, no custom components)

Simple as that. But let’s get our hands dirty and see how it works.


Creating the Screen Flow to work as List View Button

First things first, we will have to create a Screen Flow.

  1. Go to Setup

  2. Quick Find -> Flow

  3. New Flow

  1. A new tab will pop up. You need to select Screen Flow

  1. Click Create

Creating Variables

Now that we have created a shiny new flow, it’s time to create a couple of variables. I will explain how some poorly documented features of the Salesforce Flow work.

Creating ids Variable

First things first, I need to introduce you to the variable “ids”. ids variable is a Salesforce system variable, which allows you to pass multiple record ids into it. I will show you later how simple it is to use it, but first, some considerations about ids variable

  • ids variable is case sensitive. Do not use “Ids”, “IDS” or “IDs”. It will not work; it should be all lowercase.

  • When Salesforce passes values to the ids variable, they are separated by a comma. To avoid complicated extraction of record ids from text variables use the Collection Variable type of variable in the flow (we’ll get back to this in a while).


Now let’s create “ids” variable, which will store the data about our selection.

  1. Locate Sidebar in the Flow

  2. Click New Resource

  3. Create new variable

    1. Resource Type: Variable

    2. API Name: ids (remember, it’s case sensitive)

    3. Data Type: Text

    4. Allow multiple values (collection): TRUE (check the checkbox)

    5. Available for input: TRUE (check the checkbox), by checking this checkbox, we are telling Salesforce that this variable could be passed to the flow from the system. In our case, it will pass via Salesforce standard tools, after we create a list view button later in this tutorial.

    6. Click DONE

Creating Record Variables

Next, we will create another two variables. Those two will be used to store information about bulk changes we would like to make with the selected records. For simplicity I will be updating the Customer Priority standard Salesforce platform picklist field for multiple accounts.


We will create two variables - AccountSingle and AccountCollection.

  • AccountSingle will be used for the assignment element and added to AccountCollection. 

  • AccountCollection will be used to bulk update records in Salesforce to not hit Salesforce governor limits (to comply with Salesforce Flow best practices)


Now create an AccountSinge variable.

  • Resource Type: Variable

  • API Name: AccountSingle

  • Data Type: Record

  • Object: Account


Next, create an AccountCollection variable.

  • Resource Type: Variable

  • API Name: AccountCollection

  • Data Type: Record

  • Allow multiple values (collection): TRUE

  • Object: Account

Creating Flow logic for List View Button

Once we have all variables ready to rock, let’s create logic.

Add Screen Node to layout

  1. In Auto-Layout mode


  2. Click Plus sign to add a new node.

  3. Interaction -> click Screen 

  4. Add Screen Labels

    1. Label: Input Screen

    2. API Name: Input_Screen

  5. Add Picklist Component to the Screen by drag’n’dropping on it.

    1. Label: Customer Priority

    2. API Name: Customer_Priority

    3. Add 3 choices by clicking “Add Choice” button under the Configure Choices button

    1. Low

    2. Medium

    3. High

  1. Click Done.

Add Loop Node

Now we will create a Loop, which will use ids variable to loop through all the records we have selected on the List View.

  1. Click Add Element

  2. Select Loop

  3. Create Loop

    1. Name: Loop ids

    2. API Name: Loop_ids

    3. Collection variable: select ‘ids’ collection variable, which we created before.’

    4. Direction: leave as is “First to last”.

  4. Click Done.

Add Assignment Node “Assign Account”

Now we will assign values for the the accounts which have selected on the List View, plus anything we have selected on our Screen Flow.

  1. After Loop element, just under “For Each” label Click Add Element

  2. Select Assignment

Label: Assign Account

API Name: Assign_Account

Set Variable values:

  1. {!AccountSingle.Id} EQUALS {!Loop_ids}

  2. {!AccountSingle.CustomerPriority__c} EQUALS {!Customer_Priority}

  1. Click Done.

Add Assignment Node “Add Account to Collection”

  1. After Assign Account Click Add Element

  2. Select Assignment

    1. Label: Add Account to Collection

    2. API Name: Add_Account_to_Collection

    3. Set Variable Values

      1. {!AccountCollection} ADD {!AccountSingle}

    4. Click Done.











Add Update Records

  1. Just before the END node, click Add Element and add Update Records Element.

    1. Label: Update Records

    2. API Name: Update_Records

    3. Select Records to Update: {!AccountCollection}


Now you should have a Flow that look like this.

Save and activate Flow

Now, you need to Save and activate the Flow. 

  1. Save the Flow

    1. Name: Screen Flow - Update Account Field

    2. Flow API Name: Screen_Flow_Update_Account_Field

    3. Hit Save.

  2. Activate the Flow on the Top Right corner of the screen.

Pass Selected Records from List View to Screen Flow

When we are done with creating our Flow, it’s time to go ahead and add it to the List View Screen.

  1. First, we need to copy a link to our Flow, which we will need later.

    1. Go to Setup -> Flows, and locate your “Screen Flow - Update Account Field”. Next to it click on the Arrow and Click “View Details and Version”

    2. Locate URL of the flow, it should be “/flow/Screen_Flow_Update_Account_Field”. Copy that.

  2. Next Go to Setup -> Object Manager -> Account

  3. Navigate to Buttons, Links, and Actions

  4. Click New Button or Link

    1. Label:

    2. Name:

    3. Display Type: List Button

    4. In the formula field paste URL to the Flow you’ve copied earlier “/flow/Screen_Flow_Mass_Update_Customer_Priority_Field”

  5. Click Save.


At this point, you may wonder, how does Salesforce Flow know which record variable to pass to the flow? The answer is very simple. When you click a List button, selected record IDs are always added in the URL via “?ids=...”. And this is where the ids variable comes into play. Simple as that, yet not documented.

Add Flow List Button to List View

Now there is one last step. We need to add our button to the list view, so users can start enjoying it.

  1. Setup -> Object Manager -> Account, in the sidebar, locate List View Button Layout.

  2. Edit

  3. In Custom Buttons Sections, Select Update Account and add to the Selected Buttons.

  4. Click Save.

Test Your List View Button Flow

Last but not least, you can now test your flow.

  1. Go to Account

  2. Select the records you want to update

  3. Click Update Account on the top of the screen

  4. And you are good to go!


So we have learned how we can use Flows to use as List view button in Salesforce. We also learnt a way to Pass Selected Records from a List View into a Salesforce Flow.

Thank you for taking the time to read this article! I’d like to thank Lorine Kyler and Blondie Consulting for helping make this content possible. Their expertise in Salesforce Implementation Services makes them an ideal partner for companies dealing in automotive, professional services, and b2b spheres. Keep your eyes on the blog for more updates and insightful content. And don’t forget to let us know in the comments if anything was missed or if you have any questions - we love hearing from our readers! We appreciate you sticking with us, and thank you again for being here.



If you like reading my content, Subscribe to my Upcoming YOUTUBE Channel here: https://www.youtube.com/channel/UCdfi8Sq7iOcxnFhsgulWHeg/videos?view=0&sort=p&flow=grid

Don't Miss Latest Posts :  CLICK HERE TO SUBSCRIBE TO THIS BLOG

Checkout All Flow Examples on this Blog: All Flow Examples

Comments

  1. Great articel! Thank you very much. I tested it and it works but for some reasons, the last record in the collection isn't processed in my org. Could you confirm this behavior also on your side? Cheers!

    ReplyDelete
  2. Great work. Thank you for sharing. In addition, Salesforce CPQ certification validates an individual's skills and expertise in configuring, pricing, and quoting solutions in Salesforce. It demonstrates the ability to design and implement complex business processes using Salesforce CPQ. Achieving this certification can enhance one's career prospects and provide opportunities to work on exciting projects in the Salesforce ecosystem.

    ReplyDelete
  3. Great article... Just what I need for a project I am working on!

    ReplyDelete
  4. Once again thanks for this amazing blog. You done really nice work in this article. I must share this one with my good friends. Now it's time to avail vacuum sealer bags for more information.

    ReplyDelete
  5. Extremely helpful, exactly what I was looking for and the best explained out of what I have found. Now I just need to figure out how to get it on one list view and not all.

    ReplyDelete
  6. For the last step in the flow, instead of Update Records, I need to Create Records. Do you know the best solution?

    ReplyDelete
  7. Charles Thompson30 August 2023 at 02:36

    Any chance you could add a how-to for Related List buttons? This is a little more complex but follows the same principles

    ReplyDelete
    Replies
    1. Second this request. Create or clone a selected record from a related list and its child / related records.

      For example, Opportunities is a related list on Account. Click Clone Opportunity on related list and it clones Opportunities and related Cases on Account object.

      Delete
  8. This is exactly what I've been searching for! Thank you very very much!

    ReplyDelete
  9. Is there a way to limit the amount of records selected? Say only 25 records are allowed to be selected prior running?

    ReplyDelete
  10. I have one question which I am not able to solve as per my project requirements.. since we are storing all the Id in one single ids . Suppose if I have to show fault message for only the errored out records ..now currently in fault message I am getting both success and failure id due to the collection ids.. please help how it can achieve

    ReplyDelete
  11. There happens to be a flaw in the given approach. The screen element appears infinitely on selection of multiple or single records.

    ReplyDelete
    Replies
    1. does everyone has this problem?

      Delete
    2. use the retURL to redirect to a default page after the flow run, more info: https://salesforce-flowsome.com/how-to-redirect-users-returl/#returl

      Delete
  12. Great Use case and explanation . Thanks..!

    ReplyDelete
  13. When I tried that solution, since URL is encoded by Salesforce ids variable can be passed no more. Am I missing something?

    ReplyDelete

Post a Comment

Thanks for your Feedback!

PLATFORM APP BUILDER CERTIFICATION - 78% OFF

POPULAR POSTS

Salesforce Flow Examples : Flow Use Cases and Scenarios

Flow Bulkification | Mass Update Records from Flows in Salesforce


Never Miss Latest Posts