I've following plugin that run when an Invoice Product is being created from Invoice Product sub-grid or form. But it seems it don't updated the Policy Date field. I debugged the code and it run successfully but the field is not updated. Any suggestion?
try { IPluginExecutionContext context = (IPluginExecutionContext)isp.GetService(typeof(IPluginExecutionContext)); IOrganizationServiceFactory factory = (IOrganizationServiceFactory)isp.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = factory.CreateOrganizationService(context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity invoiceProduct = (Entity)context.InputParameters["Target"]; if (invoiceProduct.Attributes.Contains("invoiceid")) { Entity invoice = new Entity("invoice"); invoice = service.Retrieve("invoice", invoiceProduct.GetAttributeValue<EntityReference>("invoiceid").Id, new ColumnSet("new_policydate")); invoiceProduct.Attributes["new_policydate"] = Convert.ToDateTime(invoice.Attributes["new_policydate"]); } } } catch (Exception ex) { throw new InvalidPluginExecutionException("Error: " + ex.Message); }
*This post is locked for comments