top of page



Example of an Apex code that can use to fetch the leads that have been converted to opportunities

List<Lead> leads = [SELECT Id, FirstName, LastName, Company, Status, IsConverted, ConvertedOpportunityId
                   FROM Lead WHERE IsConverted = true];

for (Lead lead : leads) {
    System.debug('Converted lead: ' + lead.FirstName + ' ' + lead.LastName + ' from ' + lead.Company);}

Explanation :

This code will execute a SOQL query to retrieve all leads that have a value of "true" for the IsConverted field, indicating that they have been converted to an opportunity. The code will then iterate over the list of leads and print out the first and last name, company, and other information for each converted lead.

You can modify the SOQL query to include additional fields or add additional filters to narrow down the results. For example, you could add a condition to the WHERE clause to only include leads that were converted within a specific date range, or to exclude leads that have a certain status.

You can also modify the code to perform additional actions on the converted leads, such as updating fields or creating related records. For example, you could use the ConvertedOpportunityId field to retrieve the corresponding opportunity record and update a field on that record.

4 views0 comments

Recent Posts

See All

A Scratch org is a disposable, flexible, and completely isolated Salesforce environment that enables developers to test and experiment with new features and customizations without affecting the produc

Salesforce DX (Development Experience) is a set of tools and processes given by Salesforce for modern Salesforce application development and delivery. It offers a streamlined development method for de

Other Posts you may Interested 

bottom of page