Multi-Select and Mass Update Records in Lightning List Views Using Flows, Visualforce and a List Button

After the Winter ’17 release, it is now possible to select records in Lightning List views when a List View button is placed on the List View Search layout of an Object. I saw this mentioned somewhere in the Winter ’17 release notes a while ago and had been itching to try it out using a Flow custom button placed on a List view in Lightning interface. I gave it a shot this morning and it worked just I had intended it to. This opens up a plethora of opportunities to create ‘mass/bulk actions’ which can work with selected or even all of the records in a List View.

Requirement: Wayne Enterprises wants its sales reps to have the ability to mass update owners across multiple Opportunities in a Lightning list view. The sales rep should be able to select records in the list view and specify the email of the new owner which would then mass update the records’ owner to be the new person.

Solution: We will be creating three components to design and implement our solution:

  • Flow: A screen flow that would accept user’s input (Email) and then update the selected records with the new owner
  • Visualforce Page: The flow would be embedded inside this Visualforce page and the page performs the primary job of passing over the selected records in the list view into a Flow SObject collection variable.
  • Custom List Button: This button will reference the Visualforce page and will be placed on the List view

So let’s get the ball rolling.

  1. Flow

    Within the Flow, our most important variable is the following which gets its values from the Visualforce page. This variable holds the record ID’s of all the selected records in the List View.

    varSelectedOpps variable

     

    ‘Update Owner’ Flow

  2. Visualforce Page

    The VF page holds our Flow and performs the vital task of passing the selected Record ID’s into the Flow collection variable: varSelectedOpps

    Visualforce Page

  3. Custom List Button

    And last but not the least, our final component that should be placed on the List View Search Layout of the object:

    ‘Update Owner’ List button

 

Let’s place our button on the List View and see the magic happen!

List View (Click on the image to get a larger view)

Once a sales rep clicks on the ‘Update Owner’ button, our flow launches:

User Input

 

Success message

 

And on the list view, see how the owner got updated across the selected records?

Yay! (Click on the image to get a larger view)

 

I can already think of a million ways to use this technique on list views and even related lists in Classic or Lightning. Happy Flow’ing!

 

  • Eric Smith

    Any thoughts on how to apply and restrict this technique to a ‘filtered’ list? I’m thinking of use cases where you may want to perform an action on records that were selected from a list of records that would qualify for the action. For example, select only from a list of Closed Won Opportunities for a particular Account.

  • Thyrn

    Thank you for describing this excellent solution that allows to mass update records using flow. Will it be possible for you to share the content of the flow in particular the implementation of the Loop and Record Update. I tried to implement the same solution for accounts and I encountered some problem when trying to loop through varSelectedAccounts collection that is a collection of SObject type Account. I am using the loop variable selectedAccount that is type Account. It looks like the loop doesn’t execute and there is not enough information in the logs to find out why.

    • Thyrn

      I managed to solve this problem and I need to admit a very trivial mistake in my flow (not closing the for loop, I posted an idea to help to avoid this kind of mistakes: https://success.salesforce.com/ideaView?id=0873A000000E6z1QAC . Therefore my flow is working as expected. If I may suggest something I would recommend to replace Record Update from inside the loop and replace it with Fast Update outside the loop (that will update the collection of Accounts in one DML statement). This will reduce the number of executed SOQL and DML statements. For example for account mass update we could have:
      https://uploads.disquscdn.com/images/2d56ad3134f9feb3595a6b16cba09df4db35c9e38c77a567b20abb57eb824dda.png

      • rakesh behera

        Hello Mike,
        Can you help me to get that flow created, how to pass that vf page to the flow?
        I need detail screen shot. And need to implement the same in my project.

        • Thyrn

          Here is the Visualforce page that I used:

          Hope it helps.

  • Michael

    I’m having an issue with my flow. I’m trying to update a picklist value on selected records from the list view. For the Record Update Element If I put a filter by the sObject variable ID it only updates one record. If I don’t use a filter it updates all records of the custom object. https://uploads.disquscdn.com/images/f4f466fbe7a3e7cc33b903fa21812e237e9b74d232fde2eceb0ee6bcd944bc85.png https://uploads.disquscdn.com/images/29a8339823b2ad69f9f52978f8c094b040bfb5fa9769fabe36eadbf99afbf9e1.png

    • Michael

      Figured out my problem. The Loop was only iterating once since after the record update screen did not point back to the loop. As you can see from the picture above the arrow is only pointing in one direction.

  • Scott Meridew

    Would love to see a flow solution more like the ‘change owner’ capability in classic … with a selection of “user”or “queue” and a lookup to find the user or queue to transfer ownership to …

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

© 2017 Succeed With Salesforce | Website by Tonevski.com

Log in with your credentials

or    

Forgot your details?