Customizing Command Bars is often one of the first tasks Dynamics 365 developers need to learn how to do. Here are a few tricks to keep in mind that will help you avoid costly mistakes in the future.
Understand RibbonDiffXML
Dynamics CE works by storing a standard model of the Command Bar in memory. Any modifications made to the model are stored in an xml file called RibbonDiffXML. (Called this because older versions of Dynamics CRM used Ribbons in place of Command Bars). Thus, this file will have only the changes you made and nothing else.
Avoid Writing XML
There are tools that handle writing and editing the XML for you. One of the best is Ribbon Workbench. It is almost always a waste of time writing your own XML. While it can be helpful to understand it in case there’s a problem with it or if you run into unexpected behavior, generally the best solution is not editing the XML directly.
Avoid Referencing Unused Entities
Time is money. Time spent publishing is time that could be spent on other more useful tasks. Thus, it is important to prevent long publishing times. One common mistake new developers make when creating a new Command Bar solution is to import all available entities instead of only the ones they will be changing. This unnecessary importation can drastically increase publishing times because every additional entity referenced requires additional time to compile and build.
Create Separate JavaScript files for Command Bars
Shared libraries increase developer productivity by keeping them from having to “reinvent the wheel”. However, they can also become a potential maintenance nightmare and break your solutions. This can occur when a Command Bar entity references a JavaScript file that is shared between other entities, and one of them requires a change to a function. This change can affect any other entities referencing the file and potentially break Command Bar functionality. One easy way to prevent this is to create a separate JavaScript file for every entity and name them accordingly. With each entity referencing its own file, changes made to other entities and their respective files will not have unintended impacts across the solution.
Command Bars Not Showing Saved Changes
When accessing Dynamics CE online, the Command Bars and Sitemap are loaded only once, then cached. Any modifications made will not be reflected by a simple refresh. To see any changes, use a full refresh (CTL+F5 or CTL+SHIFT+R depending on the browser). This will force a full page load and reload the latest state of the Command Bars and Sitemap.