Thursday 23 February 2012

Creating dropdown menu in crm 2011 ribbon bar



<RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="Mscrm.Homepage.customentity.MainTab.Collaborate.Buttons.Form.Correspondance" Sequence="40" Location="Mscrm.Form.new_supplementarydata.MainTab.Collaborate.Controls._children">
            <CommandUIDefinition>
              <FlyoutAnchor
                Command="Mscrm.Enabled"
                Id="new.Homepage.customentity.Collaborate.Correspondance"
               
                Image16by16="$webresource:new_accept1616"
                Image32by32="$webresource:new_accept3232"
                LabelText="$LocLabels:new.customentity.Collaborate.BusinessX.LabelText"
                PopulateDynamically="true"
                PopulateQueryCommand="new.Homepage.customentity.Form.PopulateMenu"
                Sequence="14"
                TemplateAlias="o1"
               
                 PopulateOnlyOnce="true"
               
               
                Alt="$LocLabels:new.customentity.Collaborate.BusinessX.LabelText"
                ToolTipDescription="$LocLabels:new.customentity.Collaborate.BusinessX.ToolTipDescription"
                ToolTipTitle="$LocLabels:new.customentity.Collaborate.BusinessX.LabelText"
              />        
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"/>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="new.Homepage.customentity.Form.PopulateMenu">
            <EnableRules>
              <EnableRule Id="Mscrm.Enabled "/>
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="publishername.contact.WebClient.DisplayRule"/>
            </DisplayRules>
            <Actions>
              <JavaScriptFunction Library="$webresource:new_API.customentity" FunctionName="PopulateBusinessXMenu" >
                <CrmParameter Value="CommandProperties"/>
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="new.customentity.Command.Menu">
            <EnableRules />
            <DisplayRules />
            <Actions>
              <JavaScriptFunction Library="$webresource:new_API.customentity" FunctionName="BusinessXSelectedTemplate">
                <CrmParameter Value="CommandProperties"/>
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules/>
          <DisplayRules>
            <DisplayRule Id="publishername.contact.WebClient.DisplayRule">
              <CrmClientTypeRule Type="Web"/>
            </DisplayRule>
          </DisplayRules>
          <EnableRules/>
        </RuleDefinitions>
        <LocLabels>
          <LocLabel Id="new.customentity.Collaborate.BusinessX.LabelText">
            <Titles>
              <Title languagecode="1033" description="BusinessX"/>
            </Titles>
          </LocLabel>
          <LocLabel Id="new.customentity.Collaborate.BusinessX.ToolTipDescription">
            <Titles>
              <Title languagecode="1033" description="Click to select the BusinessX template"/>
            </Titles>
          </LocLabel>
        </LocLabels>
      </RibbonDiffXml>

------------------------------
and javascript is

function PopulateCorrespondenceMenu (CommandProperties) {

        var menuXml = '<Menu Id="new.Homepage.customentity.Collaborate.BusinessX.Menu"><MenuSection Id="new.Homepage.customentity.Collaborate.BusinessX.Menu.MenuSelection" Sequence="10"><Controls Id="new.Homepage.customentity.Collaborate.BusinessX.Menu.MenuSelection.Controls">';
        menuXml = menuXml + '<Button Id="new.Homepage.customentity.Collaborate.BusinessX.Menu.MenuSelection.Controls.Button1" Command="new.customentity.Command.Menu" LabelText="Button1" ToolTipTitle="Template1" ToolTipDescription="Template1 desc"  TemplateAlias="Template1 alias"  Sequence="20" Image16by16="$webresource:new_accept1616" Image32by32="$webresource:new_accept3232" />';
        menuXml = menuXml + '<Button Id="new.Homepage.customentity.Collaborate.BusinessX.Menu.MenuSelection.Controls.Button2" Command="new.customentity.Command.Menu" LabelText="Button2" ToolTipTitle="Template2" ToolTipDescription="Template2 desc"  TemplateAlias="Template2 alias"  Sequence="20" Image16by16="$webresource:new_accept1616" Image32by32="$webresource:new_accept3232" />';
        menuXml = menuXml + '</Controls> </MenuSection> </Menu>';

        CommandProperties.PopulationXML = menuXml;

    }


function    CorrespondenceSelectedTemplate (CommandProperties) {
        var controlId = CommandProperties.SourceControlId;
        alert("correspondence selected " + controlId);
    }



1 comment: