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

Wednesday, August 13, 2014

How to use Regex with GCC 4.8.2

How to use Regex with GCC 4.8.2

My setup:

Operation system: Ubuntu 14.04
Compiler: GCC 4.8.2
IDE: Eclipse 3.8.1

Problem:

I've included regex (#include <regex>) to my header file but my IDE keeps complaining that type of 'something' could not be resolved. I've tried using namespaces such as std:: and std::tr1, like people from google has adviced, with no success.

Solution:

Solution is as simple as the problem itself. If you take a look at usr/include/c++/4.8 you'll notice the regex file in root folder is kind of a stub. However there's another regex file in /tr1 folder.

The trick is, that instead of writing #include <regex>, you should write #include <tr1/regex>

After that you're able to use regex through std::tr1:: namespace.

For exmaple like this: std::tr1::smatch

Hope that helps!