Tweak Lead Qualify Process – CRM 2016

Recently, I have been asked questions about the Lead Qualification Process that why Qualify Button on lead form now doesn’t provide the ability to select the options via the dialog. And if there’s any option to modify the Lead Qualify process.

Question

Lead  Qualification process has changed a bit post CRM 2011 Upgrade. Earlier, in CRM 2011 users have the option to choose Account, Contact and Opportunity via Convert Lead Dialog Box (refer to the image below) as what you expect from a Lead Qualification Process but post CRM 2011 Upgrade (i.e. CRM 2013, CRM 2015, CRM 2016 and Dynamics 365) we don’t have that option available anymore. Qualify button now creates Opportunity.

Lead Qualification Process

It is not possible to change the OTB Lead Qualification process through Customization but possible with the help of Plugin and JavaScript.

Note – If you want to modify what is automatically copied\mapped during the various stages then you need to edit the Lead Entity Relationships.

Lead Entity

Steps to add new mapping fields to copy values from Parent to Child entity (Lead to Opportunity) during the Lead Qualify Process.

  1. Go to Settings -> Customizations ->Lead Entity
  2. Click on 1:N Relationship and select opportunity_originating_Lead
    relationship appearing under the right window pane
  3. Double click to open the relationship property and click Mappings
    under Common tab
  4. Click new if you want to add new field for mapping
  5. Select the Source Entity Field (Lead Entity as Source) and Target
    Entity Fields (Opportunity as Target)
  6. Finally, save your changes and publish your solution

NOTE-
Target and Source fields data type must match in order to progress with the mapping process. I’ve faced this issue and in my case the data type was same but there was limitation with Maximum Length type option with one of the field.

OTB Lead Qualify Process Behavior-

  1. If lead is created with the Full Name field value then an Opportunity and Contact is created.
  2. If Lead is created without the Full Name value then only Opportunity will be created.
  3. If lead is created with both the Full Name and Company Name values then Opportunity, Contact and Account record will be created.

What’s COMMON in the above three scenarios?
An Opportunity record is getting created. Well!! This may not fit every business needs.

You can control the Lead Qualify behavior with a plugin code.

Message Name – Qualify Lead
Primary Entity – Lead
Operation – Pre-Operation

Plugin Code –

protected void ExecutePreLeadQualify(LocalPluginContext localContext)
{
IPluginExecutionContext _Context = localContext.PluginExecutionContext;
//IOrganisation CRM Service
IOrganizationService _Service = localContext.OrganizationService;

// Get the qualified lead
EntityReference leadid = (EntityReference)_Context.InputParameters[“LeadId”];
OptionSetValue leadCustomerType = new OptionSetValue();

ColumnSet attributes2 = new ColumnSet(new string[] { “firstname”, “lastname” });
Entity lead = _Service.Retrieve(leadid.LogicalName, leadid.Id, attributes2);
leadTitle = lead.GetAttributeValue(“new_leadtitle”);

if (leadTitle != null)
{
//if Lead Title = Mr. or Dr.
if (leadTitle.Value == 1 || leadTitle.Value == 3) — check your optionset values or you can change if condition as per your logic
{
if ((lead.Contains(“firstname”) && lead.Contains(“lastname”)))
{
_Context.InputParameters[“CreateOpportunity”] = true;
_Context.InputParameters[“CreateAccount”] = false;
_Context.InputParameters[“CreateContact”] = true;
_Context.InputParameters[“SuppressDuplicateDetection”] = true; — To suppress the active duplicate detection rule, just simply set the SuppressDuplicateDetection property to true.
}

What is SupressDuplicateDetection?

There’re some optional parameters that you can pass to any message request by adding a value to the Parameters property. Some parameters are not exposed properties on request classes. In order to set these parameters, they must be set in the Parameters collection on the Request class.

SuppressDuplicateDetection is a Boolean used to disable duplicate detection on the following operations:

  • Create operation
  • Update operation

You can also throw new InvalidPluginExecutionException in your plugin to restricts users from qualifying the lead as per following.

if ((!lead.Contains(“firstname”) && !lead.Contains(“lastname”)) && (lead.Contains(“mobile”)))
{
throw new InvalidPluginExecutionException(“Lead record can not be Qualified due to the following missing values:
First Name & Last Name“);
}

Business Process Error

This will force the user to adapt your process rather than individual choice to skip some values and qualify the lead. This would help in saving quality data.

For more information, you can also refer to the following CRM blogs –

https://ashwaniashwin.wordpress.com/2014/04/09/modify-lead-qualification-process-in-microsoft-dynamics-crm-2013/

https://developersintent.wordpress.com/2013/10/08/hiding-duplicate-warning-dialog-box-during-lead-qualification-process/

If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on LinkedIn, Twitter or Facebook. Thank you!

 

 


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.