Showing posts with label Command bar. Show all posts
Showing posts with label Command bar. Show all posts

Monday, August 18, 2014

How to edit Microsoft Dynamics CRM 2013 command bar / ribbon by using Visual Studio 2012 and schemas

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 well

NOTE: 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
  1. Create a solution that contains concerned entity and then export the solution.
  2. Unzip solution
  3. Edit customizations.xml
  4. Zip files back to one package
  5. Import .zip file back to CRM
While steps 1, 2, 4 and 5 are pretty simple and self explatonary step 3 can be done many different ways.

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

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 files



Step 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.

Step 4. Zip files back to one package.

Again, this should be piece of cake. Just make sure that your folder structure is same than when you unzipped exported solution. Some packaging softwares tend to add one extra root folder if you're not carefull.

Step 5. Import solution (.zip file) back to CRM

Import your solution back to CRM and enjoy your customizations.

More reading

For more reading this is good place to start http://msdn.microsoft.com/en-us/library/gg309639.aspx

Saturday, October 12, 2013

Edit command bar / ribbon in Microsoft Dynamics CRM 2013

As Microsoft Dynamics CRM 2013 came out the ribbon was excluded with couple exceptions. Instead of ribbon we now have something that's called "command bar", well, because it is a command bar. However, you could think it as a "ribbon in disguise" because all modifications are still to be done through RibbonDiffXml. You can modify your RibbonDiffXml by hand or you can make your life much easier and use Ribbon Workbench software / solution. It will allow you to modify both your command bar and the ribbon. Some few entities / forms in Crm 2013 still use ribbons. Outlook client use ribbons in a certain depth as well so it's definitely something to keep in mind. I also recommend to take a look at the CRM 2013 SDK as it can help you to understand this whole concept.

Example

In this example I'm adding a simple button to my custom entity's command bar

RibbonDiffXml:


And here is what it looks like. Notice my custom webresource icon. You can find tons of icons in CRM SDK.




And this is how Ribbon Workbench looks like. I definitely recommend using it but of course it's always good to know what happens under the hood!



Resources: