Just fresh from development, a few more tools have been added to the Code Now plugin for XrmToolBox:
- Code Now can build an exe-file
- Code Now can build a plugin
- You can save your code to a file and/or load it from a file
And, because it’s CodeNow, you can do it right NOW, without even having to deploy a Visual Studio.
If you are wondering what that plugin is, you may want to read this post first:
Eventually, you should be able to download the plugin directly from the plugin store, but, for the time being, you need to download it from this site (make sure to read the post above – all those details are there)
So, how does it work with the executables/plugins?
It’s all done using the compile command. Whether the plugin will build an exe-file or a dll (for a plugin) depends on whether you have selected that “Plugin” checkbox:
Creating an exe-file
When building an exe file, the tool will take your CodeNow function and “using” directives, it will add some extra code required for the executable to compile, and it will build an “exe” file after that.
You will need to:
- Name the file when the tool asks you for it
- And click OK
Once the file is ready, and that should take just a few seconds, you’ll see that file and a few additional dll files in the folder:
In the example above, I just created that “getaccounts.exe” file.
What you still need to do after that manually(for now), you need to open getaccounts.exe.config file (if you name the file differently, this configuration file will also be named differently), and you need to configure the connection string.
Here is how it will look like when you open it:
What you see on the screenshot are a few sample connection strings which you can use to define your own connection. Just make sure to keep the same connection name (CodeNow).
If you wanted to see more examples, the msdn page below would definitely help:
Have a look at the screenshot below – I just added the connection string for my online Dynamics 365 trial instance:
And, of course, once you have configured the connection, save the file.
What you just did with the connection string only needs to be done once. Next time you compile that exe file, the configuration file will not be replaced, so, if it’s the second time you are compiling the file.. you could have skipped all those configuration steps and start your utility right away.
Remember there was that “LogMessage” method available to you when you were using “Run Code” option? Once you have an exe, LogMessage will still work, but it will be redirecting all output to the console. Here is what you are going to see then:
And that’s it. If you want, you can keep running your new utility manually. Or you can choose to schedule it.. Maybe there is something you need to do in Dynamics every morning at 6AM? Not a problem – build a utility, schedule it with Windows Task Scheduler, and don’t bother wakeing up that early anymore.
But, there is another option, too – you can also build a Dynamics plugin using CodeNow. I will explain how that works in a separate post, but, if you want, you can try it right NOW:) Or wait until tomorrow..