One of the challenges of using the Lead entity in Dynamics 365 is when you qualify a Lead from a company how to process other leads from the same organization. There hasn’t been a straightforward method to do it. Atleast until today!

Using a Microsoft Flow we can approach it from more than one angle, in the example below I will show you how to do it without modifying the OOB Lead entity.

Business Scenario: I get an inquiry from three of the Earp Family brothers, apparently they have some event they are planning that will occur at the OK Corral later in the week. They want to invite all the towns people to register for the event. They would like the to have the event information stored in their Dynamics 365 application. I show Wyatt how our Event2CRM integration with Eventbrite.com will work for them. He says it looks good and will talk to his brothers. I qualify Wyatt’s lead record to create a new Contact, Account and Opportunity. But the OOB system doesn’t provide any method to bring along Morgan’s and Virgil’s lead record and match it up with the new Earp Family account and the Opportunity.

Dynamics 365 Lead grid view

Now lets solve this challenge with Microsoft Flow.

This is the Flow I built, I will dissect it step by step. Note: for blog purposes I have only built out the Qualify path (yes path). You can essentially duplicate it with minor changes for the Disqualify scenario. Or hire us.

Convert Related Leads using Microsoft Flow

Step 1 – Use the CDS trigger When a record is updated with a filter on statuscode.

CDS Trigger when a record is selected

Step 2 – Insert two actions to get data we will need downstream in later actions. The first Get retrieves the lookups from the converted Lead record. Why? Because lookups aren’t returned from the When a record is updated trigger, only the static fields are available. The second Get retrieves the fields we need from the new Account record that was created when the lead was qualified.

Microsoft Flow CDS Trigger Get a Record

Step 3 – Insert a condition check to see if we should process the status change as a Qualified or Disqualify. If Qualified go down the yes path, in not it must be a disqualify and go down the no path.

Microsoft Flow CDS Condition Check

Step 4 – Now we need to find all the leads that are related to the lead we just converted. We will use the Company field to filter on from the lead entity. In this case we are looking for the Earp Family. We also want to exclude the lead that was just qualified using the OOB process.

Microsoft Flow List All

Step 5 – In the looping process we will do two actions. The first action is to create a new Contact record for each of the related leads and parent it with the Account created during the original lead qualification OOB process. For illustration purposes I have only mapped a few fields, in your world you will need to do a lot more mapping of Dynamic Content.

Microsoft Flow CDS Create new record

Step 6 – Now we just need to update the related leads with their lookups to the new parent account and contact and change their status to qualified. This last step can be a little tricky. Take a look at the Dynamic content for the lookups. In the case of the Account we are getting the lookup value from the original lead that was converted. In the case of the Contact we are getting the lookup from the preceding action.

Microsoft Flow Update Lead

 

Microsoft Flow Update Lead

 

Microsoft Flow Update Lead Status

That is it. No longer will you be leaving orphaned lead records from a company when you convert one from the group!

The post Convert Related Leads Solved by Microsoft Flow appeared first on CRM Innovation - Microsoft Dynamics 365 Consulting and Marketing Solutions.