Dear all,
I have registered post and preimages and wrote the following code on update of my edm_materialrequisitionform entity.
I want my code to create a purchase order when it is updated such that edm_createpurchaseorder field is yes.
When I am debugging the code, I am not getting anything in my visual studio. (The arrow is not appearing eventhough i attached it to the plugin registration tool ofcourse).
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new InvalidPluginExecutionException("localContext"); } Entity entity = null; Entity preentity = null; Entity postentity = null; if (localContext.PluginExecutionContext.InputParameters.Contains("Target") && localContext.PluginExecutionContext.InputParameters["Target"] is Entity) { entity = (Entity)localContext.PluginExecutionContext.InputParameters["Target"]; } else { return; } if (localContext.PluginExecutionContext.PreEntityImages.Contains("preimage")) { preentity = (Entity)localContext.PluginExecutionContext.PreEntityImages["preimage"]; } else { return; } if (localContext.PluginExecutionContext.PostEntityImages.Contains("postimage")) { postentity = (Entity)localContext.PluginExecutionContext.PostEntityImages["postimage"]; } else { return; }
edm_materialrequisitionform prematerialrequisitionform = preentity.ToEntity<edm_materialrequisitionform>(); edm_materialrequisitionform postmaterialrequisitionform = postentity.ToEntity<edm_materialrequisitionform>(); bool createPurchaseOrder= prematerialrequisitionform.GetAttributeValue<bool>("edm_createpurchaseorder"); if (createPurchaseOrder== true) { Entity purchaseorder = new Entity("edm_purchaseorder"); purchaseorder["edm_name"] = postmaterialrequisitionform.edm_name; purchaseorder["edm_date"] = postmaterialrequisitionform.edm_DateOfRequest; // purchaseorder["edm_customer"] = preentitymaterialrequisitionform.new_ localContext.OrganizationService.Create(purchaseorder); } } } }
*This post is locked for comments