Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Stop creating new contact and account on converting lead to opportunity

Posted on by 475

When i  click on Lead convert button it should only convert to Opportunity it should not create any new contact or account.Please suggest how to deal with this? can be done with plugin or workflow? how to implement this?

Thanks,

Krishna

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Stop creating new contact and account on converting lead to opportunity

    Hi dkrishna,

    unfortunately this is an oob behaviour based on company name / topic / firstname / lastname values.

    To avoid it you need to implement the following plugin in Pre-Operation.

    Please note this plugin require 3 new attributes on lead form: Create Account, Create Contact, Create Opportunity used to drive conversion.

    Plugin code:

    using System;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Query;
    
    namespace FP.Plugin
    {
        public class LeadQualifyPlugin : IPlugin
        {
            public void Execute(IServiceProvider serviceProvider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = factory.CreateOrganizationService(context.UserId);
    
                EntityReference leadid = (EntityReference)context.InputParameters["LeadId"];
                ColumnSet columnset = new ColumnSet(new string[] { "new_createaccount", "new_createcontact", "new_createopportunity" });
                Entity leadentity = service.Retrieve(leadid.LogicalName, leadid.Id, columnset);
    
                if (!leadentity.GetAttributeValue<bool>("new_createaccount") 
                    && !leadentity.GetAttributeValue<bool>("new_createcontact") 
                    && !leadentity.GetAttributeValue<bool>("new_createopportunity"))
                {
                    throw new InvalidPluginExecutionException("LeadQualifyPlugin.Execute error: No lead conversion options have been selected.");
                }
    
                try
                {
                    context.InputParameters["CreateAccount"] = leadentity.GetAttributeValue<bool>("new_createaccount");
                    context.InputParameters["CreateContact"] = leadentity.GetAttributeValue<bool>("new_createcontact");
                    context.InputParameters["CreateOpportunity"] = leadentity.GetAttributeValue<bool>("new_createopportunity");
                    context.InputParameters["SuppressDuplicateDetection"] = true;
                }
                catch (Exception ex)
                {
                    throw new InvalidPluginExecutionException("LeadQualifyPlugin.Execute error: " + ex, ex);
                }
            }
        }
    }

    Please let me know if you solve. 

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Verified answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Stop creating new contact and account on converting lead to opportunity

    Hi Krishna,

    Yes you can do this and it is possible by writing a pre-validation plugin on "QualifyLead" message and making "CreateContact" & "CreateAccount" to false.

    few links :

    msdn.microsoft.com/.../microsoft.crm.sdk.messages.qualifyleadrequest.aspx

    crmblocks.blogspot.in/.../how-to-qualify-lead-without-creating.html

    ashwaniashwin.wordpress.com/.../modify-lead-qualification-process-in-microsoft-dynamics-crm-2013

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans