web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • Verified answer
    Patrick Friedrich Profile Picture
    395 on at

    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"...

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans