In the previous article, I managed to cram the visual schema designer functionality into a single dll. So far I have implemented the following functionality:
- Get a list of solutions from CRM
I only get the solutions that are visisble (those are the solutions you normally see within CRM). I’m considering an option to show all solutions, I have to test first if this is a safe to do.
- Get all entities from the schema
Per entity I can filter out the custom fields (those are the fields starting with the publisher id). I intend to implement an option in which you can choose between all fields, publisher’s fields, all custom fields.
- Get all relations within the solution
I want to implement an option to show the relationship id’s and in case of a many-to-many the name of the relation.
- Save option to save the diagram
In the diagram you can remove entities and relations. This way you can make partial diagrams to highlight an aspect of the system you are designing/implementing.
- Zoom functionality
Zoom in, zoom out, by dragging a slider.
What I need to do is to transform my C# dll project into a XrmToolbox plugin project. For this subject I contacted the XrmToolBox gurus @TanguyTOUZARD (Tanguy Touzard), @rappen (Jonas Rapp) and of course @crmconsultants (Raz Dynamics). They provided me with some very helpful information on where to start.
A way to make a jumpstart in Visual Studio is by installing theXrmToolBox Plugin Project Template from the Visual Studio marketplace.
According to the market place, all I have to do is the following:
This project helps you to develop a plugin for the application XrmToolBox.
All you have to do is to create a new project from this template and start working on your plugin. It provides a default Plugin user control with all XrmToolBox capabilities:
- Connection to Microsoft Dynamics CRM/365
- Github & Codeplex links integration
- PayPal donation integration
- Settings Management
- Log Management
- and more…
Once you have created your project from this template, perform the following operations before editing the user control:
- Restore Nuget packages
- Ensure all references are resolved
- Compile the project
Then you can open visual designer for the usercontrol
I downloaded the project template and installed it on my Visual Studio environment. After restarting Visual Studio I was able to create a new XrmToolBox plugin.
After opening the project, you need to restore all NuGet packages and ensure that all references are resolved, otherwise you end up with a screen like this.
First things first, close the component desiger, and restore the NuGet packages.
Once the packages are restored and the solution is refreshed, I’m able to open the component designer. I can compile the solution. Time to start tinkering…
MyPlugin.cs is the entry point of the plugin. The class inherits from PluginBase, which is the base class from which the plugin is derived. XrmToolBox will scan for dll’s in its plugin folder, and will eventually load all dll’s implementing PluginBase. * Important stuff to know *
Furthermore, the MyPlugin class is decorated with attributes in which you can specify the appearance of the plugin in the list with plugins (title, description, colors and images).
The images you can use have to be base64 encoded. A handy way of base64 encoding images is to use the following website: base64-image.de
Once encoded you will receive a string like this:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAA ……… D9QyR6Nhuj/6zn2dCEmPSkAAAAASUVORK5CYII=
You need to select the highlighted part and paste it in either the SmallImageBase64 (32×32) or in the BigImageBase64 (80×80) attribute.
Once I compiled the plugin, I only needed to copy the plugin dll and pdb to the plugins folder within the XrmToolBox folder.
When I launch the XrmToolBox, I see my new plugin….
If I want to debug my plugin, I can attach to the XrmToolBox.exe process from within Visual Studio.
When I set a breakpoint, it kicks in when the code is being executed. Nice!
For now the first hurdle is taken. I can convert my Entity Designer into a XrmToolBox plugin, and implement the last features. Once done, I can test and debug it.
From there on I need to deploy it to the NuGet repository in order to distribute the plugin worldwide. Tanguy Touzard provided me with this page on github, in which the process is described on how to achieve this.
But first things first…. time to finish up the plugin first.