Create a Flow which will act as List View Button on Lead Object and when a user selects multiple records and clicks on our custom button "Convert Lead" then it should convert all the Selected Lead Records and Navigate back to Lead Object List View.
Hello #Trailblazer,
Welcome back, In this blog post we will see how to use a lightning flow as a list view button inside salesforce for any object.
Create a Flow which will act as List View Button on Lead Object and when a user selects multiple records and clicks on our custom button “Convert Lead” then it should convert all the Selected Lead Records and Navigate back to Lead Object List View.
As we know that we can not use flow directly in a ListView button, we will use an intermediate flow which will include the flow inside the VF page.
So in order to implement the solution, we will follow the below steps
The very first step is to create an apex class which have an Invocable method inside it to convert the lead. Below is the code which we will be using for the demo.
Now, as we have created the helper class with an Invocable Apex Method, time is to create the Flow





Save and Activate the flow
This Apex Class will be responsible for getting all the selected lead records and then preparing the public variables which we will be passing to the flow as an input. “VE_AutoLeadController” use this as the name of your Apex Class and get the code from below Gist.
The VF Page will use “VE_AutoLeadController” Apex class as an Extension and “Lead” as standard object because we will use this VF page for Lead Object List View. Page will also have the Flow inside itself
To use the flow inside VF page we use a special tag which is “flow:interview“, this tag requires min 1 variable which is the API Name of our Salesforce Flow. We can also pass the variables from VF to flow. Learn more about “flow:interview” tag. Use below code for the same
Now, as we have developed all the components, the time is to create a list view button and add it to the list view. To Create the Button follow the below instructions.


Follow the below steps to add the button to page layout

From the Lead Tab, Select “All Open Leads“, Select Multiple Records and then Click on your Custom Button


Thanks for reading 🙂 Happy #Trailblazing
Hi Amit,
Is it possible to skip the VF page here? Actually I don’t want to redirect page from the ListView. I just want to add one button at ListView and on click “Lead Convert” then display show message (Success/Error).
Regards,
Puneet
You can not directly use Flow in a List View