You are currently viewing Salesforce Lead Conversion Using Flow

Salesforce Lead Conversion Using Flow

Sharing is caring!

When the Salesforce Lead record is converted into Accounts, Contacts & Opportunities, it is called Lead conversion. When the Salesforce lead is identified as a qualified Salesforce prospect, Lead conversion occurs.

The lead conversion process is a manual process, and the lead is being converted under the following conditions:

  • When the lead data is populated in the contact, account, and opportunity. (unless specified otherwise at the time of conversion).
  • The lead status field is changed from false to true.

In this blog, we will talk about how to automate it using Apex code and Salesforce Lightning Flow.

Flow Chart To Convert the Lead

What Are The Two Steps To Convert Lead Using Flow?

There are two steps to convert lead using flow: 

  1. Create an Apex class and test class
  2. Lightning Flow Steps are:
  • Record triggered flow
  • Adding an action to Call an Apex Class

2. Lightning Flow Steps: Take the following steps to create a flow and set conditions for record triggered flow type.

How To Create A Flow And Set Trigger Conditions? 

  1. Click Setup.
  2. Search Flows in the Quick Find box.
  3. Select Flows, then click on the New Flow.
  4. Select the Record-Triggered Flow  and then follow the below steps: 
  • Freeform
  • A record is created or Updated
  • After the record is saved
  • Lead
  1. Select All Conditions Are Met (AND) as shown in the below diagram. 
  2. Set Conditions (as shown in the below diagram) as: 
    • Field: Lead | Rating
    • Operator: Equals 
    • Value: Hot
  3. Choose the Option to Only when a record is updated to meet the condition requirements.
  4. Click Done.

Moving forward, we will show you how to create an Apex class and a Test class. 

  1. How to Create an Apex class and Test class?
  1. Click Setup.
  2. Type Apex Classes in the Quick Find box.
  3. Clicks on the New button.
  4. Copy code from the below and paste it into your Apex Class. 
  5. Click Save.

public class AutoConvertLeads {


    public static void assignLeads(List<Id> LeadIds){

        LeadStatus cLeadStatus=[Select Id,MasterLabel from LeadStatus where isConverted=true limit 1];

        List<Database.LeadConvert> massLeadConvert=new List<Database.LeadConvert>();

        for(Id currentLead:LeadIds){

            Database.LeadConvert LeadConvert=new Database.LeadConvert();







            List<Database.LeadConvertResult> lcr=Database.convertLead(massLeadConvert);

            system.debug(‘lcr:: ‘+lcr);




  • Lightning Flow – Call an Apex Class 
  • Under Toolbox, select Element. 
  • Drag-and-drop Action element onto the Flow designer. 
  • In the Action box, type AutoConvertLeads.
  • Click on the AutoConvertLeads apex class as shown in the below diagram:
  • Enter a name in the Label field; the API Name will auto-populate.
  • Set Input Values: 

Row 1:

LeadIs: {!$Record.Id}

  •  Click Done.

Finally, we have to run the record-triggered flow after saving the record to take the action of the auto conversion of leads. 

How to Add an Action? 

  1. Click Save.
  2. Enter Flow Label and the API Name will LeadConversion
  3. Click Show Advanced.
  4. Type: Record-Triggered Flow
  5. Interview Label: Auto Convert Leads {!$Flow.CurrentDateTime}
  6. Click Save. 

If a user updates the Lead Rating to Hot, Lightning Flow will automatically convert such leads and create an account and a contact. 


Lead conversion in Salesforce is the process of converting Salesforce Lead records into Accounts, Contacts & Opportunities.  It occurs when the Salesforce lead gets identified as a qualified Salesforce prospect. A lead is the default object in Salesforce created after receiving new contact information in your database. Leads can be imported or created automatically through an external marketing automation platform and form submissions. Lead conversion in Salesforce can be done using Apex Code and Lightning Flow that help businesses get a return on their investment.


Nitish Bhardwaj

Salesforce Principal Consultant | Chief Information Officer
An experienced professional with 5+ years of experience in consulting on and delivering Salesforce projects for mid size, large and very large customers.

Hire the best Salesforce Implementation Partner. Choose certified Salesforce Implementation Experts from Cloud Analogy now.

Leave a Reply

× How can I help you?