Monday, September 4, 2023

Plugin Development: Create and Register Plugin - Dynamics 365 CE - Part 2

Title: Plugin Development: Create and Register Plugin - Dynamics 365 CE - Part 2


This tutorial is a continuation of Plugin Development. Kindly follow the following link for part 1 to create the plugin solution.  

Part1: Plugin Development: Create and Register Plugin - Dynamics 365 CE - Part 1


Step 5: Register the Plugin 

 

 

Register your plugin within the Dynamics 365 CE environment. This step tells the system when and where your plugin should execute. 


To register a plug-in, you will need the Plug-in Registration tool – download it from here. https://learn.microsoft.com/en-us/power-apps/developer/data-platform/download-tools-nuget  


Launch the Plugin Registration tool and Connect to the Dataverse 


Click PluginRegistration.exe to open.  


 

 

Select Office 365, click Show Advance to Enter login credentials for the Dataverse.  

Hit Login 

 

 

After you are connected, you will see any existing registered plug-ins, custom workflow activities and data providers. 

 

 

Now click on Register dropdown and click Register New Assembly 

 

 

In the Register New Assembly dialog, select the ellipses (…) button and browse to the assembly you built in the previous step. Go to the Solution location > bin > debug folder 

Select the Plugin DLL and Hit Open 

 

 

Review the Plugin Assembly and click Register Selected Plugins.  

For Dynamics 365 online, isolation mode is set to Sandbox and Location to store the assembly is Database 

 

 

You will see a Registered Plug-ins confirmation dialog. 

 

 

Click OK to close the dialog; your plugin Assembly registered will be displayed under the Organization. 

 

 

Step 6: Register for a new Plugin Step. 


Plugin Step says how, when and where plugin will run and execute.  

Right-click the (Plugin) and select Register New Step. 


 

 

In the Register New Step dialog, set the following fields: 

  1. Message – Create  

  1. Primary Entity – account  

  1. Event Pipeline Stage of Execution – PostOperation (plugin will run after record creation) 

  1. Execution Mode – Synchronous (plugin will execute synchronously) 

 

 

Click Register New Step: you can see the registered step.  

 

 

Now, let's assume after deployment, you made some changes to Plugin code, and you need to update the Assembly.  

Just build the solution again, go to Plugin registration tool, select the (Assembly) from the list, click Update from ribbon, browse the Assembly DLL, remember to Select All check box, click Update Selected Plugins. 

 

 

 

Step 7: Test the Plugin  

After deployment of your plugin to your Dynamics 365 CE environment and test it thoroughly.  

Go To your Dynamics 365 Environment > open an App > and Create new Account 

On the Timeline section, you will see the Task Created.  

  

 

Trace Log: 

By default, plug-in trace logs are not enabled. Enable the plug-in trace logs 

Navigate to Advance Settings > under System > Administration 

 

 

In Administration, select System Settings. 

 

 

In the System Settings dialog, on the Customization tab, set Enable logging to plug-in trace log to All. 

Click OK 

 

 

 

To view the Plugin Trace Log, navigate to Settings > Customization > Plug-In Trace Log  

 

 

OR Open Advance Find look for Table Plug-in Trace Logs and click Results 

 


 

Open the Record to see the Trace Log Information.  

 

 

 

 

Best Practices for Plugin Development 

 1. Modular Coding: Divide your logic into reusable modules for maintainability. 

2. Error Handling: Implement robust error handling to ensure smooth operation. 

3. Avoid Infinite Loops: Carefully design your plugin to avoid triggering an infinite loop of events. 

4. Logging: Utilize logging mechanisms to track plugin execution and troubleshoot issues. 

5. Testing: Test your plugin in a sandbox environment before deploying it to production. 

  

 

*Conclusion 

Dynamics 365 CE plugins open the door to endless possibilities for customization, automation, and integration. By mastering the art of creating plugins, you're equipped to unleash the full potential of Dynamics 365 CE and tailor it precisely to your organization's needs.  

 


Stay tuned for more in-depth explorations into the Dynamics 365 CE Platform and Plugin Development. 

#Dynamics365 #Development #Plugin #PowerApps #PowerPlatform 

 



Next Steps: Learn more about other powerful features of Plugin!