[Tools] Code Now
- Amraoui Hamza
- Aug 25, 2021
- 1 min read
Updated: Aug 26, 2021
Running C# Code Into Dynamics CRM

XrmToolBox library contains a variety of tools for different purpose. One of the interesting tools is Code Now.
This tool is about running C# code into dynamics organisation. The tool is developed by Alex Shlega available on XrmToolBox library

How To Get Started?
After connecting to dynamics organization, open the tool, then past your code in Source Code(c#) Area and hit Run Code Button

Example : Get all account names and display them in the log window
This code is about getting all the account in the connected organization based on the fetchXml query, and display them in the log windows.

Keep in mind that :
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
The full documentation available here.
i hope it helps.
Commentaires