Skip to main content

How to debug a plugin in Dynamics 365 online using plugin profiler

Ref: https://dynamics365blocks.wordpress.com/2016/12/06/how-to-debug-a-plugin-in-dynamics-365-online-using-plugin-profiler/

How to debug a plugin in Dynamics 365 online using plugin profiler
In this post we’ll learn how one can debug a plugin code in Dynamics 365 online or Dynamics CRM online environment.
What you need is dynamics 365 SDK which ou can download from here.
Below is the Step by Step procedure to debug a plugin in Dynaamics 365/Dynamics CRM online:
Step 1: Download and extract Dynamics 365 SDK  in any folder.
Step 2: Now navigate to SDK\Tools\PluginRegistration
Here you’ll see pluginRegistration.exe file.

Double click on it and create a new connection.by clicking “Create New Connection”
1
Step 3: Click on login. It’ll ask for credentials.
Provide your dynamics 365 username and password and click sign in.2.PNG
Step 4: Now it’ll display the available instances of your organization.
Select the one in which your plugin exist you want to debug.
It’ll display the list of existing assembly deployed in that  instance.

Step 5: Click on install profiler button on top ribbon of Plugin Registration tool.
3.PNG
Once it’s done, it’ll look like this:
4.PNG
Also a solution is created in Dynamics CRM instance as shown below:
5.PNG

Step 6: Now select the step you want to debug in plugin registration tool and click Start Profiling.6
Click ok in next window:
7.PNG
As you click OK,the plugin step is updated as below:
8.PNG
Step 7: Now perform the operation on which the above step has been registered.
It’ll generate an exception and a log file which you need to download and save.
It’ll be used in step 9.
Step 8:  Now open the plugin solution in Visual studio and Add the breakpoint  in plugin code from where you would like to debug.
Now click on debug and then click attach to process.
Below window will pop up where you need to select PluginRegistration.exe adn click on attach:
9.PNG
Step 9: Now click on debug in plugin registration tool as shown below:
10.PNG
Now below window will open where you need to select the log file downloaded in step 7 in Profile, specify plugin dll assembly location in Assembly location and select the step in Plugin as shown in below image and click “Start Execution“:
11.PNG
Step 10: As soon as you click on Start Execution, the debugger stops at the breakpoint inserted in code in step 8 as shown in below screenshot:
12.PNG

Now you can debug the code line by line further by pressing F10.

Comments

Popular posts from this blog

Microsoft Dynamics 365 CRM Troubleshooting Solution Import Errors

Remember when CRM life was so much simpler that solutions did not yet exist? If you had separate development and production environments and you wanted to move your customizations, you simply clicked  Export Customizations  and voila! It was done. Those were the days. Nostalgia Warning – in case you’ve forgotten, here’s a screenshot to jog your memory: With CRM 2011, the concept of solutions was introduced, giving us a new set of powers – by picking individual entities, workflows, etc., we now had the ability to group together and move only those customizations we wanted to include in our solution. The next great solutions advancement came with CRM 2016: we can now select specific components within each individual entity – so instead of moving the entire contact entity, for example, we have the option of moving only a certain view or field within the entity. And we can do this without having to hack the xml in the zip file. (By the way, if you want to learn more abou...

How to Filter SubGrid Lookup view in Dynamics 365 CRM

How to Filter SubGrid Lookup view in Dynamics 365 CRM.  Please check the comments in the below code and do follow the steps accordingly and call the  filterSubGrid() funtion on onload. var LastQuery = ""; function filterSubGrid() { debugger; setSubgridLookupFiltering(); } function AddLookupFilter(entity_type, customFilter) { var subgridLookup = Xrm.Page.getControl("lookup_Contacts_Participants"); subgridLookup.addCustomFilter(customFilter, entity_type); } function setSubgridLookupFiltering() { var subgridAddButtonId = "Contacts_Participants_addImageButton"; //Try to get the element from both the current and the parent document. var subgridAddButton = document.getElementById(subgridAddButtonId) || window.parent.document.getElementById(subgridAddButtonId); //This script may run before the subgrid has been fully loaded on the form. If this is the case, //delay and retry until the subgrid has been loaded. if (subg...

How to prevent record from saving in Dynamics CRM using Javascript

  From time to time you might need to add some validation to the save event of an entity, this actually used to be an approach I would use on a regular basis but since the introduction of business rules have found myself doing this less and less. But still, knowing the ability is available is handy. When you define the onsave event function, you must tick the “Pass execution contact as first parameter” option. (See below) Having done that you can create an onSave function with code similar to the example I have shown below. Note forgetting the “(context)”, which will take the context parameter allowing you to prevent the save when needed. function onSave(context) { var saveEvent = context.getEventArgs(); if (Xrm.Page.getAttribute("telephone1").getValue() == null) { // *** Note: I am using an alert for testing a notification maybe better! alert("Put in a phone number!"); saveEvent.preventDefault(); } } Note: This simple example might be better achi...