Pages

Thursday 3 April 2014

How to add menu button in CRM 2011 ribbon


The following post describes that how to add menu options for ribbon button in CRM 2011. The code is in XML format.

Using flyoutAnchor tag, we can create menu options.

<?xml version="1.0" encoding="utf-16"?>
<RibbonDiffXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <CustomActions>
    <CustomAction Id="new.incident.Button1.Button.CustomAction" Location="Mscrm.Form.incident.MainTab.Actions.Controls._children" Sequence="10">
      <CommandUIDefinition>
        <FlyoutAnchor Command="Mscrm.Enabled" Id="new.incident.Button1.Button" Image16by16="$webresource:new_status16" Image32by32="$webresource:new_status32" LabelText="$LocLabels:new.incident.Button1.Button.LabelText" Sequence="10" TemplateAlias="isv">
          <Menu Id="new.incident.Button1.Button.Menu">
            <MenuSection Id="new.incident.Section2.Section" Title="$LocLabels:new.incident.Section2.Section.Title" Sequence="10" DisplayMode="Menu16">
              <Controls Id="new.incident.Section2.Section.Controls">
                <Button Command="Mscrm.incident.Command0.Command" Id="new.incident.Button3.Button" LabelText="$LocLabels:new.incident.Button3.Button.LabelText" Sequence="20" />
              </Controls>
            </MenuSection>
            <MenuSection Id="new.incident.Section4.Section" Title="$LocLabels:new.incident.Section4.Section.Title" Sequence="30" DisplayMode="Menu16">
              <Controls Id="new.incident.Section4.Section.Controls">
                <Button Command="Mscrm.incident.Command1.Command" Id="new.incident.Button5.Button" LabelText="$LocLabels:new.incident.Button5.Button.LabelText" Sequence="40" />
              </Controls>
            </MenuSection>
          </Menu>
        </FlyoutAnchor>
      </CommandUIDefinition>
    </CustomAction>
  </CustomActions>
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates" />
  </Templates>
  <CommandDefinitions>
    <CommandDefinition Id="Mscrm.incident.Command0.Command">
      <EnableRules />
      <DisplayRules />
      <Actions>
        <JavaScriptFunction FunctionName="fixCase" Library="$webresource:new_CaseStatus" />
      </Actions>
    </CommandDefinition>
    <CommandDefinition Id="Mscrm.incident.Command1.Command">
      <EnableRules />
      <DisplayRules />
      <Actions>
        <JavaScriptFunction FunctionName="processCase" Library="$webresource:new_CaseStatus" />
      </Actions>
    </CommandDefinition>
  </CommandDefinitions>
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules>
      <DisplayRule Id="new.incident.DisplayRule0.DisplayRule">
        <FormStateRule State="Existing" Default="true" />
      </DisplayRule>
    </DisplayRules>
    <EnableRules>
      <EnableRule Id="new.incident.EnableRule0.EnableRule">
        <FormStateRule State="Existing" Default="true" />
      </EnableRule>
    </EnableRules>
  </RuleDefinitions>
  <LocLabels>
    <LocLabel Id="new.incident.Button1.Button.LabelText">
      <Titles>
        <Title description="Status" languagecode="1033" />
      </Titles>
    </LocLabel>
    <LocLabel Id="new.incident.Section2.Section.Title">
      <Titles>
        <Title description="Fix Case" languagecode="1033" />
      </Titles>
    </LocLabel>
    <LocLabel Id="new.incident.Button3.Button.LabelText">
      <Titles>
        <Title description="Fix Case" languagecode="1033" />
      </Titles>
    </LocLabel>
    <LocLabel Id="new.incident.Section4.Section.Title">
      <Titles>
        <Title description="Process Case" languagecode="1033" />
      </Titles>
    </LocLabel>
    <LocLabel Id="new.incident.Button5.Button.LabelText">
      <Titles>
        <Title description="Process Case" languagecode="1033" />
      </Titles>
    </LocLabel>
  </LocLabels>
</RibbonDiffXml>

No comments:

Post a Comment