How to edit Microsoft Dynamics CRM 2013 command bar / ribbon by using Visual Studio 2012 and schemas
NOTE: Applies also to Microsoft Dynamics CRM 2011 and probably to other versions of Visual Studio as wellNOTE: In CRM 2011 what used to be called Ribbon is now basically called Command Bar in CRM 2013 even though it's not basically the same thing. Ribbons are available in CRM 2013 as well (Outlook client for example).
Preface
Usually I would recommend editing MS CRM 2013 / 2011 ribbon / command bar by using 3rd party tools such as Visual Ribbon Editor or Ribbon Workbench.Sometimes though, it is desired, that editing is made by hand. You'll face these situations more likely when you don't have an access to install 3rd party softwares or you just wanna be hardcore... or any other reason.
I would divide editing (manual editing) process into five steps
- Create a solution that contains concerned entity and then export the solution.
- Unzip solution
- Edit customizations.xml
- Zip files back to one package
- Import .zip file back to CRM
You could just open Notepad++ and start editing and hope that everything is in place when you import your solution back. Or you could open Visual Studio, attach schemas from the SDK and make your life much easier.
You will need
- Microsoft Dynamics CRM 2013 SDK
- Visual Studio 2012 (other versions probably will be fine)
- CRM Online / On-premises
Step 1. Create a solution and export it
The first step is to create a solution that contains entity / entities whose ribbon(s) you want to edit. You could just export the default solution but for the sake of the peace of mind I recommend you to create a new solution that contains only entities you really want to edit. Otherwise your customization.xml will be really big and hard to read (even with modern editors such as Visual Studio). In this example I'm editing account's command bar.Step 2. Unzip solution
Unzip the solution to any folder you wish. You'll end up with at least these three filesStep 3. Edit customizations.xml
Now this is the part actual work happens. First I want you to open customizations.xml with your Visual Studio.Then you should open File Properties window. You can open it from View -> Properties Window or by pressing F4.
After that open Schemas window by pressing the button with three dots in it (see picture below).
Now select the following schema files (.xsd files) from the CRM 2013 SDK (SDKFolder\Schemas) by pressing Add... button
Then click OK. Now you may wonder how this will help you. When you attach these schema files to your xml file it tells to Visual Studio automatically check your xml file against schema files. So it's real time validation.
But even better advantage (imo) is that you'll get Intellisense. So no longer you need to constantly go and see what properties are available and for what node. Visual Studio will tell you.
Take this as an example. I want to add new button to account's form. I know that I need to add custom action node under custom actions but I'm not quite sure how to continue from there. I could go to MSDN and find out, or I could save time and let Visual Studio tell me.
So as you can see I wrote only "<" and Visual Studio told me that under CustomerAction node there should be CommandUIDefinition. If I just add CommandUIDefinition and leave it like that Visual Studio can tell me that it is incomplete and that I still need to add something before it matches the schemas.
So it goes without saying that this is really neat feature and it can save you alot of time. The good rule of thumb is that when your xml passes validation it should be okey for importing. But do not take that for granted either.