Search This Blog

Loading...

Tuesday, April 19, 2011

How to: Change existing ribbon element properties

Today, I will try to explain you how to change properties of existing ribbon elements. For this example, I will change the label and icon of the button “New opportunity” in the main grid ribbon of the entity “Opportunity”.

The standard ribbon for the opportunity looks like the below one:

RibbonOpportunity1

And the result I expect:

RibbonOpportunity2

To obtain this result, follow the below procedure:

1 - If it is not already done, download the SDK (click here).

2 - Open the SDK folder “samplecode \ cs \ client \ ribbon \ exportribbonxml \ exportedribbonxml”. Then open the Xml file corresponding to the entity (here opportunity.xml). In our case, the button “Nouveau” (or “New” in english), is the one we need to retrieve:

<Button Id="Mscrm.HomepageGrid.opportunity.NewRecord" ToolTipTitle="$Resources:Ribbon.HomepageGrid.MainTab.New" ToolTipDescription="$Resources(EntityDisplayName):Ribbon.Tooltip.New" Command="Mscrm.NewRecordFromGrid" Sequence="10" LabelText="$Resources:Ribbon.HomepageGrid.MainTab.New" Alt="$Resources:Ribbon.HomepageGrid.MainTab.New" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" />


3 - Create a new solution with the opportunity entity included and export it.


4 - Add a CustomAction with the correct location in the CustomActions node of the customizations.xml file contained in the exported solution archive. Only two attributes are required:



  • An identifier of your choice
  • A location (the location of the existing button): You will find the correct location in the parent node of the existing Xml button (in the opportunity.xml file). It is the attribute “Id” of the parent node. The location will be the concatenation of this id and the term “._children”.

5 – Add the Xml of the existing button


6 – Change the properties of the button (here, highlighted in yellow)


<RibbonDiffXml>
<CustomActions>
<CustomAction Id="MSCRMTools.HomepageGrid.opportunity.MainTab.Management.Controls"
Location="Mscrm.HomepageGrid.opportunity.MainTab.Management.Controls._children">
<CommandUIDefinition>
<Button Alt="$Resources:Ribbon.HomepageGrid.MainTab.New"
Command="Mscrm.NewRecordFromGrid"
CommandType="General"
Id="Mscrm.HomepageGrid.opportunity.NewRecord"
Image16by16="/_imgs/ribbon/NewRecord_16.png"
Image32by32="/_imgs/FormEntity/ico_fhe_3.png"
LabelText="Nouvelle"
Sequence="10"
TemplateAlias="o1"
ToolTipDescription="$Resources(EntityDisplayName):Ribbon.Tooltip.New"
ToolTipTitle="$Resources:Ribbon.HomepageGrid.MainTab.New" />
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates" />
</Templates>
<CommandDefinitions />
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules />
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>




7 – Import back the solution, that’s it!

9 comments:

Vladislav Osmanov said...

That's simple, eh?

Anonymous said...

I would like to ask, if it is possible to change ribbon bar labels using Translation?

weber a said...

I would like to ask, if it is possible to change ribbon bar labels using Translation? ==> me too. i probably cant handle with sdk

Vadim said...

Great post, you help me a lot of time, thanks.

Anonymous said...

This code uses label by loclabels

Vee Eee Technologies said...

Thanks for the post. It was very interesting and meaningful.
Vee Eee Technologies

Anonymous said...

Is it possible to get string values of "$Resources:Ribbon.HomepageGrid.MainTab.New" or "$Resources:Ribbon.HomepageGrid.MainTab.New"?
I tried to find them but could not do it.

Unknown said...

I'm who asked about "$Resources:..." string values, I found some of them exporting translations for Default solution, but not all of them. There were missing a lot of OOB ribbon strings (label texts, tooltips, descriptions).

Anonymous said...

editing ribbon elements