- 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
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|
|Entity "Movie" Record|
|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|
|Export Solution Screen 2|
|Export Solution Screen 3|
|Export Solution Screen 4|
|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:
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.
|Final Code after Adding a Custom Ribbon Button|
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".
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|
|Import Solution Screen 2|
|Import Solution Screen 3|
|Import Solution Screen 4|
|Import Solution Screen 5|
|New Custom Ribbon Button "Revenue" Added|
|New Custom Ribbon Button "Revenue"|