Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Qualifying Lead Creates Account and Contact Records - Change Default Values?

(0) ShareShare
ReportReport
Posted on by 285

When you qualify a lead, CRM automatically creates the corresponding Account and Contact records based on the basic info you entered in the lead. I would like to set certain fields in those two new records to certain values to distinguish these records as not being our customers yet. Is there a way to set this through some built in way? The workarounds I can think of would be to:

  1. Modify the default value settings for the fields so that this sort of automated process sets the fields to the defaults which are configured to show that the account is in the opportunity process. (This makes me think that maybe a calculated field value can be set based on the existence of a relationship between the account record and an active opportunity/lead)
  2. Create a workflow that, on some trigger that is currently unclear to me, sets a specific field, that distinguishes an "opportunity account" from an active customer, to the desired value.

Any suggestions on how to accomplish this best would be appreciated.

*This post is locked for comments

  • Verified answer
    Patrick Friedrich Profile Picture
    395 on at
    RE: Qualifying Lead Creates Account and Contact Records - Change Default Values?

    Hi Artemy,

    you can use the originatingleadid field when qualifying a lead. If the contact or customer is created and the field is filled, then setup a workflow to populate some values from the lead to the new records or just set some standard values to mark them as "not customers yet"...

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Qualifying Lead Creates Account and Contact Records - Change Default Values?

    Hi Artemy,

    if you want to solve with cut and paste, use the following plugin.

    It requires 3 new boolean attributes: Create Account, Create Contact, Create Opportunity. If none of these are selected, this plugin throws an error.

    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.

    Francesco

    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,850 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans