Flow: How To Handle Converted Lead’s Related Records (Account/Contact/Opportunity)

Can we convert Leads in Flow? Unfortunately, it is still impossible without a custom Apex invocable method (You can check out this solution on Automation Champion if interested). However, it is possible to modify the related records of a converted Lead in Flow. It is very easy as well, so let’s take a look at how to achieve this!

Introduce Conversion Fields

There are several system fields on Lead object that we can use in order to edit the related records. They are: IsConverted, ConvertedAccountId, ConvertedContactId, and ConvertedOpportuntiyId (Official Documentation). IsConverted is showing whether the current Lead is a converted Lead. If True, the Converted Account/Contact/Opportunity Id fields will be populated as well. We can then use these fields to query out the related records.

How To Set Up In Flow

You can simply create a Record-Triggered Flow on Lead object when Updated or Created/Updated. The condition should be IsConverted = True. Ideally, you want to run the Flow “only when” the Lead is converted. You should then use the second option on when the run the Flow, even though the chance that you will update the converted Lead record is low.

Then simply use a Get Records or Update Records to get the record you want. Please note that if you convert a Lead to an existing Account, the Flow will run again on that existing account and potentially rewrite the data. If you don’t wish that to happen, add more constraints using CreatedDateTime for example.

Use Cases

1. Need To Apply Custom Logic

Even though we can map the Lead fields to Account/Contact/Opportunity, it requires we map the fields of the same type with the same value. If we want to add custom logic, we can utilize Flow and these fields. For example, change the Account Rating to Hot if the Lead has high potential or is marked by the sales teams.

2. Need To Add Additional Records

The standard conversion only allows us to create Account, Contact, and Opportunity. If you want to create other records like Opportunity Product, Task, Events, etc, you can do them all together in one Flow instead of building several Flows on different objects. It can also better illustrate your business process – so you have one Flow for Lead conversion-related tasks, instead of one on Account, one on Opportunity, and so on. This makes the management of your automation a lot easier.

Is This Helpful? Check Out Flow Use Cases Or Write Us One!

Subscribe
Notify of
guest

6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
YossiH

Thanks! Helped me 🙂

Tomáš Gerö

Your procedure seems logically correct, I came to the same solution, but the lead conversion does not trigger. As conversion isn’t a lead update.
Have you some idea what I’m doing wrong, thank you.

Manish K

I tried to run a trigger on the opportunity record, after insert it executed the trigger upon lead conversion but still there were no updates on the converted opportunity.

here is the code I used

trigger OpportunityGCLIDTrigger on Opportunity (after insert) {
    // Collect the IDs of related Marketing Activities
    Set<Id> marketingActivityIds = new Set<Id>();
    
    for (Opportunity opp : Trigger.new) {
        // Check if the Opportunity is associated with a Lead
        if (opp.ConvertedAccountId != null) {
            // Retrieve the related Marketing Activities from the converted Lead
            marketingActivityIds.add(opp.ConvertedAccountId);
        }
        
        // Check if the Opportunity is associated with a Contact
        if (opp.ContactId != null) {
            // Retrieve the related Marketing Activities from the associated Contact
            List<Id> contactMarketingActivityIds = [SELECT Id FROM CampaignMember WHERE ContactId = :opp.ContactId AND GCLID__c != null];
            marketingActivityIds.addAll(contactMarketingActivityIds);
        }
    }
    
    // Fetch the GCLID data from related Marketing Activities
    Map<Id, MarketingActivity__c> campaignMembers = new Map<Id, MarketingActivity__c>([SELECT Id, GCLID FROM MarketingActivity__c WHERE Id IN :marketingActivityIds]);
    
    // Update the GCLID field on Opportunities
    for (Opportunity opp : Trigger.new) {
        if (campaignMembers.containsKey(opp.ConvertedAccountId)) {
            opp.GCLID__c = campaignMembers.get(opp.ConvertedAccountId).GCLID__c;
        }
        
        if (campaignMembers.containsKey(opp.ContactId)) {
            opp.GCLID__c = campaignMembers.get(opp.ContactId).GCLID__c;
        }
    }
}
Markus Keller

I have a similar solution in my org. But instead of a picklist field, we use a text field LeadId. This helped us in the past to do some data migration from Lead to Contact. It has the LeadId of the Lead that created the Contact.

Matt

Hey,
maybe someone has an idea for my problem.
I have a Flow with entry condition IsConverted = true. It was working correctly and is still working in old sandboxes.
But now, it’s not working in prod and in newly created sandboxes. I guess that the Flow isn’t able to see the converted leads (also if the running user has permission to see it – but the flow should be triggered by system).

I think there was a change in the settings which prevents the system/flow from “seeing” converted leads – so it’s not triggered.

Do you have an idea which setting this could be?

Debasmita Bakshi

it works

Last edited 11 months ago by Debasmita Bakshi