Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

(0) ShareShare
ReportReport
Posted on by 3,497

I have a PreValidation plugin on Account, which simply ensures that the OOB name field is a concatenation of certain custom fields on Account.

This Plugin works as expected in all cases, except when Accounts are created as part of the 'Lead Qualification' process.

Furthermore, I created a workflow to do the same and noticed that when the Account was created as a part of the Lead Qualification Process, neither the plugin nor the workflow is triggered.

I understand this is not a bug, but more of an 'undocumented' functionality. I would like to know why the CRM system behaves so, and any possible workarounds for my requirement.

TIA!

*This post is locked for comments

  • Suggested answer
    Nuno Profile Picture
    Nuno 2,005 on at
    RE: PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

    Hi Shidin,

    If you want to keep your plugin on account create outside of transaction, keep it on ple-validation and to handle the account create when qualifying leads, register a new plugin on qualifylead message on post-operation.

    On this message on post-operation you are able to access the account created

    // Message: QualifyLead, Stage: PostOperation
    // get created account from collection of created entities 
    EntityReference accountId = (context.OutputParameters["CreatedEntities"] as EntityReferenceCollection).FirstOrDefault(x => x.LogicalName == "account");
    
    if (accountId != null)
    {
          Entity account = service.Retrieve(accountId.LogicalName, accountId.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(false));
    
         // Your logic here
    
    }


  • Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

    Hi Nuno,

    Thank you for the suggestion. Yes, I see that the plugin is triggered now.

    Interestingly, the PreValidation plugins are not triggered during the LeadQualify step, but the PreOperation ones are triggered.

    I am assuming that the 'QualifyLeadRequest' step handles the security check, so that there is no need for the PreValidation plugins to be triggered.

    Is there any way to perform the operation outside of transaction?

    Regards,

    Shidin

  • Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

    Hi Felippe,

    Thank you for your reply.

    My main concern here was to reduce having to create one more plugin to do the job. And rather use the existing plugin itself.

  • Verified answer
    Nuno Profile Picture
    Nuno 2,005 on at
    RE: PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

    Hi Shidin,

    Change the stage of your plugin from pre-validation to pre-operation and your plugin will work.

  • Suggested answer
    Felippe Profile Picture
    Felippe 796 on at
    RE: PreValidation Plugin on Account not firing when Account created through Lead Qualify Process

    Hi Shidin Haridas,


    You can handle that with the Sdk Message QualifyLead.
    Build a plugin on PostQualifyLead step, and retrive the Account record created.
    After that, do your concatenation checklist. At this moment the account record has already created on database, and you can delete it if your conditions aren't satisfied.
    If want to handle the creation or not of the Account based on the checklist, check the mapped fields from Lead to Account, and make the validation at PreQualifyLead.

    See this articles to support your development:
    https://mscrmmindfire.wordpress.com/2013/04/29/using-plug-in-get-the-created-records-when-lead-was-qualified/
    And
    msdn.microsoft.com/.../microsoft.crm.sdk.messages.qualifyleadrequest.aspx


    If this solves, please "Like" and mark as "Verified Answer".

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans