Notifications
Announcements
No record found.
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
Hi,
Do you get any error, or just nothing happens?
As described here you cannot debug a plugin in CRM Online, you need to use tracing:
msdn.microsoft.com/.../gg328574.aspx
Andres, he is using PRt to debug his plugins, so your answer is irrelevant
Sorry, overlooked it.
Please check this blog how to correctly debug with profiler:
www.inogic.com/.../how-to-debug-plugins-using-profiler
make sure the plugin dll deployed in CRM online equals the locally referenced dll file.
My problem is not in how to debug. My problem is I am missing something in the logic.
I debugged so many times before.
Hello Pawel,
I think It is in the logic itself. Something which has to do with images.
No I do not get any error when I debug. The debugger runs and gives nthing, not even the arrow to debug.
Hello,
Paweel what is entity alias in the plugin registration tool when registering an image?
What type of field is "edm_createpurchaseorder"?
Is it possible that the check to see if that field is set to "yes" could be incorrect?
The code related to the creation looks correct.
Maybe put the creation code higher up and outside of the "create PO" check just to see if you can get it to execute.
// Instantiate an account object.Entity myPO = new Entity("edm_purchaseorder");// Set the required attributes. myPO["edm_name"] = "The Name Here";
myPO["edm_date"]= DateTime.Today();// Create an account record named Fourth Coffee._myPOId = _orgService.Create(myPO);
Maybe you misspelled your images names? Make sure that in PRT when registering preimage,you put "preimage" (case sensitive) in name and alias and also the same for postimage. Based on your code I would assume that in InputParameters you are lacking "preimage" or "postimage" and the plugin just ends it's running before it even hits the part with record creation
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2