We all know about XrmToolBox – it’s a tool of choice for a lot of Dynamics consultants. Although, it is, really, a set of tools rather than just a single one.. But, either way, you’ve likely heard about it.
Worst case scenario – you just learned about it from this post.. in which case I would actually insist that you download the tool right now (hint: it’s free) from the XrmToolBox web site:
So, let’s assume you have XrmToolBox, and let’s say you know how to use it. How about using it for the strange purpose of running C# code into Dynamics? After all, XrmToolBox is, already, connected to your Dynamics organization, so all you are missing is an XrmToolBox plugin that will allow you to run the code.
To tell you the truth, I just wanted to see how it works out.. It did work – see below:
1. Download XrmToolBox plugin from this url:
2. Deploy that plugin to the XrmToolBox folder
– Unpackage that zip file
– Put the dll you’ll find there into the XrmToolBox plugins folder (which is: %AppData%\MscrmTools\XrmToolBox\Plugins )
3. Restart (or open) XrmToolBox – you’ll see another plugin there
(Yes, I know.. I should have added some nice logo)
4. Don’t open it yet – first, connect to your Dynamics organization
5. Then open the plugin
6. You can, actually, hit “Run Code” – the code will run and it will print account names for all accounts in your Dynamics organization
What if you wanted to change the code?
First of all, feel free to do it! What you have there by default is just an example to get you started.
However, keep in mind a few things:
- You have to have a public static void CodeNow() method in your code
- You can use Service property (IOrganizationService) and LogMessage method in your code (sure you can use others.. but that Service will already be connected to Dynamics, and LogMessage will print a message in the log area of the plugin)
- Do not define classes or namespaces in this version, just use static methods. Actually, you can probably define a class.. I did not try but it should work
- In the “Using” area, add all the namespaces just like you would do it in your regular C# file
- Here is the list of referenced assemblies your code can use: System.Drawing.dll, Microsoft.IdentityModel.dll, System.ServiceModel.dllSystem.Runtime.Serialization.dll, Microsoft.Xrm.Sdk.dll, Microsoft.Xrm.Tooling.Connector.dll,Microsoft.Crm.Sdk.Proxy.dll
Continue reading about CodeNow plugin: Syntax Highlighting
PS. Since CodeNow plugin has a home page now, don’t be a stranger – stop by any time: http://www.itaintboring.com/tcs-tools/code-now-plugin-for-xrmtoolbox/