Dynamics CRM

Qualifying Leads and how to prevent creating an account, contact or opportunity

The default process of qualifying a lead creates an opportunity, a contact and an account, if the fields are filled in. But how we can control, which entities are created?

If you create a lead, there are some default required fields, like the topic and the name. Entering the name, you get an additional dialog, to fill in the first name and last name separately.

This information is used during qualification to create a contact with the provided first- and last name.

Default lead form

 

There is also a section named company, where you past in the company name. This field is business recommended and will be used to create the account with this name during qualification.

Also, an opportunity is created during qualification. The opportunity is always created and after the qualification process is finished, the user will be redirected to the newly created opportunity.

But how to prevent creation of all three entities?

default business process flow of the lead in dymaics 365

If you don’t like to create an account and a contact, you can use the default process flow. There are two fields called “Existing Contact?” and “Existing Account?” If you set this lookups to an existing entry, they won’t be created a second time.

Example: You set the lookup of the account, save the lead and click qualify. The system will create a new contact and a new opportunity, but no new account.

But what can you do, if you want to decide, which entity should be created?

First, you create three new fields fo type TwoOptions, called

  • new_CreateAccount
  • new_CreateContact
  • new_CreateOpportunity

Put these fields on the form, that the users can select, which entity should be created.

Now there are two possible solutions.

Solution 1: Using Workflows

You create a new field on each of the three entities and map this field with the corresponding create-field of the lead. Now, if you qualify the lead, the entities will be created and the value of the create-field of the lead will be transferred to the field on the entity.

Now create a new workflow, that will be executed on the creation of the entity and check, if the field is set to yes. If this is the case, delete the entry.

This solution can be used without writing a single line of code, but on each qualification, the system will create the entires and afterwards (based on the value of the creation field) will delete them again.

 

Solution 2: Using Plugins

The second solution would be, to create a new plugin with the following implementation on Execution:

 

Register this plugin with the message QualifyLead on the lead entity. Use the stage Pre-validation.

Register QualifyLead Plugin

In the plugin, you can get and set the information on the Input Parameters of the Context. The used parameters are:

  • CreateAccount
  • CreateContact
  • CreateOpportunity

If you set the attribute to false, this entity won’t be created during the qualification process. But be aware, that if you don’t create an opportunity, the CRM system can’t redirect to the opportunity and therefore, there is no visible action during qualification.

You have to manually reload the lead, to see, that the lead is qualified.