Even though we are provided with a lot of freedom when it comes to customizing Microsoft’s Dynamics 365 we still run into a scenario now and then where to fine tune our CRM experience we have to take help of Coded customizations. Dynamic 365 uses JavaScript and c# to achieve this fine-tuned customization. JavaScript in Dynamics 365 is stored in web resource folder
Use of JavaScript in Dynamics 365
JavaScript in Dynamics 365 is used to access and customize Form scripts, ribbon commands and web resources
JavaScript in dynamics 365 is mainly used to customize forms and add custom validation logic to fields to validate data entered by the user for that specific field. Apart from validation JavaScript can be used to access many other elements using object returned by Xrm.Utility.getGlobalContext (); which returns the same context provided by Xrm.Utility.getGlobalContext which is now deprecated and soon be removed. We can set dynamic values to fields using this context
To use our own custom JavaScript we must upload our script file in web resources folder which in itself comes with a text editor which provides us ease of editing our uploaded code without re-uploading it every time we make a change in our script, after uploading our JavaScript we must publish it and refresh the page to make our changes visible
Use of C# in Dynamics 365
While JavaScript takes care of the frontend fine tune customization c# comes in handy to create plugins that help with data processing aspect of the CRM. Whenever a plugin runs in dynamics 365 it follows a pipeline execution model
1. Pre-Event(Pre-Validation stage)- It executes before the main system operation and it does not involve a database transaction. These plugins are synchronous i.e. these plugins are executed immediately and run in a specific order
2. Pre-Event(Pre-operation stage)-It executes before the main system operation and is executed within the database transaction. These plugins too are synchronous
3. Platform Core Operation (Main operation stage)- This is the main operation stage, No plugins are registered during this stage it will always be either before the main operation stage or after
4. Post-Event(Post-operation stage)- Plugins registered on this stage executes after the main operation and they execute within the database transaction only if they are set as synchronous plugin
To register our plugins with the CRM we need a plugin registration tool through which we can register our plugins and attributes it works on
With these two important tools we can streamline our customizations In Dynamics 365 and tailor the best CRM according to our business needs