Useful CRM Tips

Useful CRM Tips...

Friday, June 29, 2012

Create a Custom Group in Entity Ribbon Main Tab

For this, I have opted the WorkRequest(custom Entity), in this entity ribbon am going to create a new custom group and place three custom buttons in that.

for this first we need to export the customization of that entity then edit the
RibbonDiffXml of that entity as follows.

In the <CustomActions/> node place this code to create the new custom group on the main tab of the respective entity and also add custom buttons to that group

then define the command definations (which also contains the actions to be peformed by the custom buttons) for the controls(buttons) & custom group as we declared above
<CustomActions>
          <CustomAction Id="Mscrm.Form.new_work_request.CustomGroup.CustomAction"
                        Location="Mscrm.Form.new_work_request.MainTab.Groups._children"
                        Sequence="110">
            <CommandUIDefinition>
              <Group Id="Mscrm.Form.new_work_request.CustomGroup.Group"
                      Command="Mscrm.Isv.new_work_request.Form.Group0"
                      Title="ISV WorkRequest Button Group"
                      Sequence="51"
                      Template="Mscrm.Templates.Flexible2">
                <Controls Id="Mscrm.Form.new_work_request.CustomGroup.Controls">
                  <Button Id="Mscrm.Form.new_work_request.Form.Group0.Control0"
                          Command="Mscrm.Isv.new_work_request.Form.Group0.Control0"
                          LabelText="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control0.LocLabel"
                          ToolTipTitle="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control0.LocLabel"
                          ToolTipDescription="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control0.LocLabel"
                          Image16by16="/_imgs/ribbon/customaction16.png" Image32by32="/_imgs/ribbon/customaction32.png"
                          Image16by16Class="ms-crm-Upgraded-Ribbon-Image16"
                          Image32by32Class="ms-crm-Upgraded-Ribbon-Image32"
                          Sequence="10"
                          TemplateAlias="o1" />
                  <Button Id="Mscrm.Isv.new_work_request.Form.Group0.Control1"
                          Command="Mscrm.Isv.new_work_request.Form.Group0.Control1"
                          LabelText="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control1.LocLabel"
                          ToolTipTitle="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control1.LocLabel"
                          ToolTipDescription="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control1.LocLabel"
                          Image16by16="/_imgs/ribbon/customaction16.png"
                          Image32by32="/_imgs/ribbon/customaction32.png"
                          Image16by16Class="ms-crm-Upgraded-Ribbon-Image16"
                          Image32by32Class="ms-crm-Upgraded-Ribbon-Image32"
                          Sequence="10"
                          TemplateAlias="o1" />
                  <Button Id="Mscrm.Isv.new_work_request.Form.Group0.Control2"
                          Command="Mscrm.Isv.new_work_request.Form.Group0.Control2"
                          LabelText="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control2.LocLabel"
                          ToolTipTitle="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control2.LocLabel"
                          ToolTipDescription="$LocLabels:Mscrm.Isv.new_work_request.Form.Group0.Control2.LocLabel"
                          Image16by16="/_imgs/ribbon/customaction16.png"
                          Image32by32="/_imgs/ribbon/customaction32.png"
                          Image16by16Class="ms-crm-Upgraded-Ribbon-Image16"
                          Image32by32Class="ms-crm-Upgraded-Ribbon-Image32"
                          Sequence="10"
                          TemplateAlias="o1" />
                </Controls>
              </Group>
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="Mscrm.Form.new_work_request.CustomGroup.MaxSize.CustomAction"
                        Location="Mscrm.Form.new_work_request.MainTab.Scaling._children"
                        Sequence="120">
            <CommandUIDefinition>
              <MaxSize  Id="Mscrm.Form.new_work_request.CustomGroup.MaxSize"
                        GroupId="Mscrm.Form.new_work_request.CustomGroup.Group"
                        Sequence="21"
                        Size="LargeLarge" />
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="Mscrm.Form.new_work_request.CustomGroup.Popup.CustomAction"
                        Location="Mscrm.Form.new_work_request.MainTab.Scaling._children"
                        Sequence="140">
            <CommandUIDefinition>
              <Scale    Id="Mscrm.Form.new_work_request.CustomGroup.Popup.1"
                        GroupId="Mscrm.Form.new_work_request.CustomGroup.Group"
                        Sequence="85"
                        Size="Popup" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>

also define the command definations for the custom ribbon buttons as we declared above.

<CommandDefinitions>
          <CommandDefinition Id="Mscrm.Isv.new_work_request.Form.Group0">
            <EnableRules />
            <DisplayRules />
            <Actions />
          </CommandDefinition>
          <CommandDefinition Id="Mscrm.Isv.new_work_request.Form.Group0.Control0">
            <EnableRules />
            <DisplayRules>
              <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control0" />
            </DisplayRules>
            <Actions>
              <Url Address="/../Castweb/Issues/ISF.aspx?source=new_work_request&amp;OrderTypeId=2" PassParams="true" />
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="Mscrm.Isv.new_work_request.Form.Group0.Control1">
            <EnableRules />
            <DisplayRules>
              <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control1" />
            </DisplayRules>
            <Actions>
              <Url Address="/../Castweb/Issues/ISF.aspx?source=new_work_request&amp;OrderTypeId=1" PassParams="true" />
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="Mscrm.Isv.new_work_request.Form.Group0.Control2">
            <EnableRules />
            <DisplayRules>
              <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control2" />
            </DisplayRules>
            <Actions>
              <Url Address="/../Castweb/Issues/ISF.aspx?source=new_work_request&amp;OrderTypeId=3" PassParams="true" />
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>

also define the rule definations for the custom ribbon buttons as we declared above.

<RuleDefinitions>
          <TabDisplayRules>
          </TabDisplayRules>
          <DisplayRules>
            <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control0">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control1">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.Isv.new_work_request.Form.Group0.Control2">
              <FormStateRule State="Create" InvertResult="true" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules />
        </RuleDefinitions>

and also define the local labels as we declared above.
<LocLabels>
          <LocLabel Id="Mscrm.Isv.new_work_request.Form.Group0.Control0.LocLabel">
            <Titles>
              <Title languagecode="1033" description="Display" />
            </Titles>
          </LocLabel>
          <LocLabel Id="Mscrm.Isv.new_work_request.Form.Group0.Control1.LocLabel">
            <Titles>
              <Title languagecode="1033" description="Search" />
            </Titles>
          </LocLabel>
          <LocLabel Id="Mscrm.Isv.new_work_request.Form.Group0.Control2.LocLabel">
            <Titles>
              <Title languagecode="1033" description="Technology" />
            </Titles>
          </LocLabel>
        </LocLabels>


finally a custom group with some custom buttons is defined under the main tab of the entity & looks like below.

No comments:

Post a Comment