Hi Laurent, You can also accept my answer : Please make sure you define plugin step following: Messages : Delete Event Pipeline Stage of Execution : Pre-Validation And also don't forget to create pre image under step public class DeletePlugin: IPlugin { public void Execute(IServiceProvider serviceProvider) { //Extract the tracing service for use in debugging sandboxed plug-ins. ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); // Obtain the execution context from the service provider. IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext)); // 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 parameters. Entity entity = (Entity)context.InputParameters["Target"]; if (entity.LogicalName != "YourEntityName") //Need to replace with your entity return; try { if (context.PreEntityImages != null && context.PreEntityImages.Contains("PreImage")) { Entity BeforeDeleteEntity = (Entity)context.PreEntityImages["PreImage"]; // Get Pre Image of the entity /// Your Logic Here } } catch (FaultException ex) { throw new InvalidPluginExecutionException("An error occurred in the FollowupPlugin plug-in.", ex); } catch (Exception ex) { tracingService.Trace("FollowupPlugin: {0}", ex.ToString()); throw; } } } }
↧