Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
First of all, why would you need to build a plugin in the XrmToolBox? Isn’t it what the Visual Studio is for?
I think the answer is “yes and no”. See, if you are a developer and have all the tools.. you probably don’t need to read this post (other than out of curiosity). But, if you are a Dynamics administrator, or, maybe, you are a developer who just needs to create a plugin quickly while you are away from your work computer.. Whatever the reason is, if you do need to create a plugin for Dynamics, and if you don’t have Visual Studio installed, you can do it with the CodeNow plugin easily now.
Before you continue, you may want to get CodeNow plugin installed, so here is where you’ll find the instructions:
Once you have it installed, the process looks like this:
For the plugin registration tool, you will find a detailed walkthrough here:
In this post, I’ll walk you through the steps required to compile a plugin in XrmToolBox.
Here we go:
1. Open XrmToolBox and load CodeNow plugin
2. Select “Plugin” checkbox
Once you have selected the checkbox, CodeNow will display sample plugin code. You can actually use “Compile” command to compile plugin dll at this point, but it won’t, really, be very functional yet.
However, that sample code has all the basic code you need to start with..
So, why don’t we create a plugin for the account entity that will ensure that nobody will set account name to “Test”
3. Here is the code we are going to add
if(entity.Contains("name") && (string)entity["name"] == "Test")
throw new InvalidPluginExecutionException("Cannot use 'Test' for the account name");
4. It’s time to compile the plugin?
When you click “Compile”, the tool will ask you for the dll file name, so.. just choose the file name you want. “Test.dll” might be just fine:
5. Now you can use the PluginRegistrationTool to register the plugin
And the SDK step, of course:
6. And, now, let’s do a quick test. Let’s try to update the account’s name:
Worked out just as we planned!