Hi Andrew, Here are the relevant bits public class PreOrderClose : 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); ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { tracer.Trace("Enter Entity Check"); targetEntity = (Entity)context.InputParameters["Target"]; tracer.Trace("Check Parent"); if (context.ParentContext != null) // Gives Error { IPluginExecutionContext parent = context.ParentContext; tracer.Trace(""); tracer.Trace("Parent"); Entity org_Order = (Entity)parent.InputParameters["Target"]; //Do rest of logic. Includes editing order products hence why it's pre-create
↧