Add Dropdown Menu to CRM 2011 Ribbon

I am new to crm 2011. I found documentation on how to add a new button to the ribbon. And how to group buttons. But I need a dropdown menu button on the ribbon. How can i do this? I did not find any information about this.

Thanks!

+7
source share
1 answer

This should help you get started. If all you need is a static menu, you can place the tag inside the departure control and create a menu there.

<FlyoutAnchor Id="Sample.account.form.FlyoutAnchor.Static" Sequence="10" Command="Mscrm.Enabled" Image16by16="/_imgs/placeholders/ribbon_placeholder_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" LabelText="Sample Flyout" Alt="Sample Flyout" TemplateAlias="isv"> <Menu Id="Sample.account.form.Menu"> <MenuSection Id="Sample.account.form.MenuSection" Title="Menu Section Title" Sequence="15"> <Controls Id="Sample.account.form.MenuSection.Controls"> <Button Id="Sample.account.form.Controls.Button.FirstButton" Command="Sample.ButtonCommand.Command" LabelText="First Button" ToolTipTitle="First Button" ToolTipDescription="The first button" TemplateAlias="isv" Sequence="20"/> </Controls> </MenuSection> </Menu> </FlyoutAnchor> 

If you want to generate the Dynamically menu, you can use this departure control. Note the added padding attributes. Then you need to create the menu through javascript.

 <FlyoutAnchor Id="Sample.account.form.FlyoutAnchor.Dynamic" Sequence="10" Command="Mscrm.Enabled" Image16by16="/_imgs/placeholders/ribbon_placeholder_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" LabelText="Sample Flyout" Alt="Sample Flyout" PopulateDynamically="true" PopulateQueryCommand="Sample.PopulateDynamicMenu" TemplateAlias="isv" /> 

I have created two commands that access javascript functions. DynamicMenu creates a menu, and a search is used to determine which button click was clicked. Please note that both of them pass the CommandProperties parameter, this is important for javascript.

 <CommandDefinition Id="Sample.PopulateDynamicMenu"> <EnableRules> <EnableRule Id="Mscrm.Enabled" /> </EnableRules> <DisplayRules /> <Actions> <JavaScriptFunction FunctionName="DynamicMenu" Library="$webresource:a_JavaScript_File"> <CrmParameter Value="CommandProperties" /> </JavaScriptFunction> </Actions> </CommandDefinition> <CommandDefinition Id="Sample.SearchCommand"> <EnableRules /> <DisplayRules /> <Actions> <JavaScriptFunction FunctionName="Search" Library="$webresource:a_JavaScript_File"> <CrmParameter Value="CommandProperties" /> </JavaScriptFunction> </Actions> </CommandDefinition> 

Here are the javascript functions:

 function DynamicMenu(CommandProperties) { ///<summary>Dynamically generate menu items based on context</summary> /// <param name="CommandProperties"> /// Command properties crm parameter sent from the ribbon. object used to inject the Menu XML /// </param> var menuXml = '<Menu Id="Sample.DynamicMenu">' + '<MenuSection Id="Sample.Dynamic.MenuSection" Sequence="10">' + '<Controls Id="Sample.Dynamic.Controls">' + '<Button Id="Sample.account.form.Controls.Button.FirstButton"' + ' Command="Sample.SearchCommand"' + ' LabelText="First Button"' + ' ToolTipTitle="First Button"' + ' ToolTipDescription="The first button"' + ' TemplateAlias="isv"' + ' Sequence="20" />' + '</Controls>' + '</MenuSection>' + '</Menu>'; CommandProperties.PopulationXML = menuXml; } function Search(CommandProperties) { ///<summary>Determines which control was pressed</summary> /// <param name="CommandProperties"> /// Command properties crm parameter sent from the ribbon. object used to read which dynamically generated /// button is selected. /// </param> var controlId = CommandProperties.SourceControlId; switch (controlId) { case 'Sample.account.form.Controls.Button.FirstButton': alert(controlId + ' was pressed!'); break; default: alert('unknown'); } } 
+13
source