locked
CRM 2015: Simple Post Update Plugin Executing Multiple times RRS feed

  • Question

  • I have been having a issue with a really simple plugin on the quotedetail entity.

    I have removed all logic from my plugin and am doing a simple log to a text file to see how many time it gets invoked. Its seems to get called 7 times on a single save on a line item on  a quote. I was expecting my plugin only to execute once or maybe I'm missing something.  I also only have 1 line item on the quote.

    My Plugin code is:

    namespace e92plusMSCRM.Plugins
    {
        using System;
        using System.Data;
        using System.Collections.Generic;
        using System.ServiceModel;
        using Microsoft.Xrm.Sdk;
    
        /// <summary>
        /// QuoteProductPostCalculateTotals Plugin.
        /// Fires when the following attributes are updated:
        /// All Attributes
        /// </summary>    
        public class QuoteProductPostCalculateTotals : IPlugin
        {
            public void Execute(IServiceProvider serviceProvider)
            {
    
                // Obtain the execution context from the service provider.
                IPluginExecutionContext context =
                    (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
                // safe-guard recursion
                if (context.Depth > 1)
                    return;
    
                // The InputParameters collection contains all the data passed in the message request.
                if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
                {
                    // Obtain the target entity from the input parmameters.
                    Entity entity = (Entity)context.InputParameters["Target"];
                    ErrorLogger.Log("Plugin executed!");
                }
            }
    
        }
    }

    Plugin registration:


    With filtering:

    Log file has:

    How can i have my post update plugin only execute once?

    Kind regards

    Andrew

    Thursday, October 22, 2015 10:23 AM

All replies