Saturday 19 January 2013

Microsoft Dynamics CRM 2011 - Adding a new Custom Ribbon Button

One of the best new features of CRM 2011 has to be "The Ribbon". CRM 2011 Ribbon is customizable. We can add custom buttons, add events to buttons, hide/unhide buttons, enable/disable buttons, add button groups, etc.

A custom ribbon button could be used in following scenarios:
  • There is a requirement for some user interactivity. 
  • If there is a requirement to display additional information about a record by simply clicking a button
  • If there is a requirement to execute business logic for a record by simply clicking a button

In this blog I will show how to add a new custom ribbon button to a custom entity form.

I will add a custom ribbon button labelled "Revenue" on one of my custom entity form. The custom entity is called "Movie". This entity has movie records. After adding, when we open any movie record, the button will be displayed on the ribbon. This button is supposed to calculate and display the revenue for the movie. In this blog I will only show how to add a ribbon button.

The ribbon customization is inside the entity form xml. I will create an unmanaged solution to which I will add the "Movie" entity. I will export this solution, add the ribbon button code, import the solution and publish the changes. The movie record will then display the new ribbon button.

1) I will create a new unmanaged solution called "Ribbon_new_Movie".

Unmanaged Solution

2) In this solution add the existing entity "Movie". Select "No" at "Missing Required Components" screen. We are only interested in the required entity "Movie".

Select "No" to Missing Required Components

Add "Movie" Entity to the Unmanaged Solution

3) Below is the "Movie" entity record form, before I add a new custom ribbon button. The red arrow is pointing to the place where the new ribbon button will be displayed.

Entity "Movie" Record
4) I will go to my Solutions and select unmanaged solution "Ribbon_new_Movie" to export. Click on the "Export" button.

Select the Solution "Ribbon_new_Movie" to Export

5) The solution export process will take you through various screens. I will display all the screens below. Make your selection as per what I have done below. At the end you will be asked to save your solution. I have saved the solution by its default name.

In below screen, I don't need to publish changes. So click "Next".

Export Solution Screen 1
I don't need any related components. Ignore the warning and click "Next".

Export Solution Screen 2
 Don't select any advanced settings below as we don't need any. Click "Next".

Export Solution Screen 3
Since I am not interested in a managed solution, so I will keep the default "Unmanaged" selection. Click "Next". 

Export Solution Screen 4
I will save the solution by the default name in one of my folders. The solution is saved as a zip file.

Export Solution Screen 5


6) I will unzip the solution file in the same location.

Solution File Unzipped

7) There are 3 files. We are interested in "customizations.xml". This XML file contains the code where we will add our custom ribbon button code.

You can open and modify this XML file in Visual Studio OR any XML editor OR any notepad of your choice. I am editing this in Visual Studio 2010 IDE.

"customizations.xml" in Visual Studio 2012

8) This file contains XML for the "Movie" entity form. This form code contains a section where we can enhance and customize the ribbon. Search for the markup in the code <RibbonDiffXml>. The code section between <RibbonDiffXml> and </RibbonDiffXml> is where we can customize the Ribbon.

If we open this section without any previous customizations done, it will look like:

RibbonDiffXml Code

The RibbonDiffXml is named as such because any code added here is the Ribbon Difference on top of the out of the box Ribbon. It has various markups like CustomActions, Templates, CommandDefinitions, RuleDefinitions, LocLabels and RibbonNotSupported.

<CustomActions>: We can define our custom buttons.
<Templates>: Define a ribbon template.

<CommandDefinitions>: We can define the rules ID and action web resources.

<RuleDefinitions>: We can define the actual rules to enable/disable or hide/unhide buttons.

<LocLabels>: Can contain the LocLabel elements.

<RibbonNotSupported>: Indicates that the entity does not support the ribbon.

9) I will add the code for a new custom ribbon button. The final code between the RibbonDiffXml markup will look something like:

Final Code after Adding a Custom Ribbon Button

I have defined a custom action. In this I define where to display the button. I have defined the location of the button as Location = "Mscrm.Form.new_movie.MainTab.Collaborate.Controls._children". This means the custom button will be displayed on the main tab of the form and within the "Collaborate" group.

I have defined the actual button inside the "CommandUIDefinition" markup. Inside button I have defined various attributes. One of them is Command = "Mscrm.HomepageGrid.new_movie.MovieRevenue.Command". In command we can define the display rules and actions around the button. For this blog I have just defined a placeholder value and not defining any actual rule. This means the custom button will be displayed and active at all times but will do nothing when clicked. 

The "LabelText" defines the button display name. The text in "ToolTipTitle" and "ToolTipDescription" will be displayed when you take your mouse over the button. They describe what the button does.

Inside "Image16by16" and "Image32by32" we can define the image icons for the button. In CRM there is a folder "_imgs" inside the CRM installation directory. In my case the location of "_imgs" is the default location at "C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_imgs". This folder contains icon images used by CRM. You can either select any image from there or use your own custom image. I have selected already present icon images "InvoicePaid_16" and "InvoicePaid_32".

I have also defined a placeholder for rules inside "CommandDefinitions" and "CommandDefinition". The Id="Mscrm.HomepageGrid.new_movie.MovieRevenue.Command" has the same value which I had defined in button as Command = "Mscrm.HomepageGrid.new_movie.MovieRevenue.Command". This way we can bind the rules and actions to the button. For this blog I have just created placeholder and not creating any rules and actions. I have created this placeholder to show where we can enhance the button functionality. I will write blogs in the future to show how to enable/disable, hide/unhide and fire JScript on a custom ribbon button.

10) After changing the XML in the file "customizations.xml" now we have to import it back. Include this "customizations.xml" file from unzipped location back to the zipped file. We can open the zipped file, drag and drop the changed file back in.

Now import this changed zip file back into CRM.

Go to CRM Solutions and click Import.

Import the Solution

I have pasted the screenshots for every screen in the import process. Select the unmanaged zip file to import.

Import Solution Screen 1
Ignore the warning. This warning indicates we cannot uninstall this solution. Since there is no such requirement, so we can ignore this warning. Click "Next".

Import Solution Screen 2
This will start the import process.

Import Solution Screen 3
This screen shows us that the solution import process has been completed successfully.

Import Solution Screen 4
Click "Publish All Customizations". This will publish all the changes which I did on the "Movie" entity form.

Import Solution Screen 5
11) When I open the "Movie" entity form, the new custom button "Revenue" appears where I had intended it to be.

New Custom Ribbon Button "Revenue" Added
If I take my mouse over this button I can see the text values I added for "ToolTipTitle" and "ToolTipDescription" in the XML file.

New Custom Ribbon Button "Revenue"

I hope this blog about 'Microsoft Dynamics CRM 2011 - Adding a new Custom Ribbon Button' was informative. Please feel free to leave your comments.

Update on Microsoft Dynamics CRM 2011 Update Rollup 12 Release

By Bob Stutz - Corporate Vice President, Microsoft Dynamics CRM


I'd like to give an update on the Microsoft Dynamics CRM 2011 Update Rollup (UR) 12 Release. We originally made UR12 available on Thursday, January 10th, to deliver multi-browser support for our On Premises customers. After discovering an issue that could potentially impact a customer's database, we withdrew the UR12 Server bits to ensure that no On Premises customers would be affected. Unfortunately, these bits were available on the Microsoft Download Center for a short period of time. If you downloaded the UR12 Server bits, please do not install them. We plan to repost the UR12 Server bits within the next week, and we will keep you informed as to when they are available. We have taken measures to improve our engineering processes and methodologies going forward, and we take your feedback very seriously. We apologize for any inconvenience this has caused.


I hope this blog about 'Update on Microsoft Dynamics CRM 2011 Update Rollup 12 Release' was informative. Please feel free to leave your comments.

Monday 7 January 2013

Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Write Java and other Non-.NET Client Applications

Developers that use Java, or other non-.NET technologies can write applications that use data from Microsoft Dynamics CRM 2011.

You can also access data from Microsoft Dynamics CRM 2011 using the WSDL from the web service.

The Microsoft Dynamics CRM SDK contains sample code that demonstrates how to use Java to access Microsoft Dynamics CRM Online and perform Create, Read, Update, and Delete operations. This sample code uses Windows Communication Foundation (WCF) and the SOAP interface to access the operation data and metadata API published by Microsoft Dynamics CRM Online. The sample code can be found in the folder Walkthroughs\Java2CRM\Java2CRMCRUD.

This walkthrough uses Eclipse but the steps for using NetBeans are similar.

My above blog is based on Microsoft's Official information.
 
I hope this blog about 'Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Write Java and other Non-.NET Client Applications' was informative. Please feel free to leave your comments.