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 :
Customer experience | Sales, Customer Insights,...
Unanswered

Dynamics 365 Custom plugin not triggering

(0) ShareShare
ReportReport
Posted on by 410
I have a custom plugin that sets the default values for Account. Contact, and Opportunity to No when a Lead is Qualified:
 
using Microsoft.Xrm.Sdk;using Microsoft.Xrm.Sdk.Query;using System;using System.Collections.Generic;using System.Linq;using System.Runtime.Remoting.Services;using System.Text;using System.Threading.Tasks;using System.Web.UI.WebControls;namespace PreOperationQualifyLead{    public class PreOperationQualifyLead : IPlugin    {        public void Execute(IServiceProvider serviceProvider)        {            ITracingService tracingService = null;            try            {                var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));                tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));                // Check if the message is QualifyLead                if (context.MessageName != /QualifyLead/)                {                    tracingService.Trace(/Plugin not triggered by QualifyLead message. Exiting plugin./);                    return;                }                var orgFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));                var orgService = (IOrganizationService)orgFactory.CreateOrganizationService(context.InitiatingUserId);                // Log the start of plugin execution                tracingService.Trace(/PreOperationQualifyLead plugin execution started./);                // Validate and retrieve input parameters                if (context.InputParameters.Contains(/CreateAccount/) &&                    context.InputParameters.Contains(/CreateContact/) &&                    context.InputParameters.Contains(/CreateOpportunity/) &&                    context.InputParameters.Contains(/Status/) &&                    context.InputParameters.Contains(/Target/))                {                    var isCreateAccount = (bool)context.InputParameters[/CreateAccount/];                    var isCreateContact = (bool)context.InputParameters[/CreateContact/];                    var isCreateOpportunity = (bool)context.InputParameters[/CreateOpportunity/];                    var status = (Int32)context.InputParameters[/Status/]; // Assuming Status is an integer                    var leadEntRef = (EntityReference)context.InputParameters[/Target/];                    // Add custom logic to determine action based on parameters                    // For example, skip contact and account creation during Qualify process                    context.InputParameters[/CreateContact/] = false;                    context.InputParameters[/CreateAccount/] = false;                    // Log the completion of plugin execution                    tracingService.Trace(/PreOperationQualifyLead plugin execution completed successfully./);                }                else                {                    // Log if required input parameters are missing                    tracingService.Trace(/One or more required input parameters are missing./);                }            }            catch (Exception ex)            {                // Log any exceptions that occur during plugin execution                if (tracingService != null)                    tracingService.Trace(/An error occurred: / + ex.ToString());                throw new InvalidPluginExecutionException(/An error occurred in the plugin./, ex);            }        }    }}
The Plugin is registered to the SandBox instance for testing and Step is registered
In Plugin assemblies in Power Platform, I can see the plugin also there
Also, the plugin step is there and it's On
However, testing the plugin by Qualifying Lead is not doing anything, the values for Account and Contact are still by default Yes (instead of No as the plugin must do).

Note: Opportunity is No by default, so this values is not thanks to the plugin!

There are no System Jobs or Plugin-trace logs in CRM, so I'm guessing it is not running at all. Any Help what should I do from here to troubleshoot this?

I have the same question (0)

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans