【问题标题】:Adding a button to account entity homepage's ribbon/command bar向帐户实体主页的功能区/命令栏添加按钮
【发布时间】:2014-11-08 22:58:20
【问题描述】:

在使用功能区时,我尝试在帐户实体主页的功能区/命令栏上添加一个按钮,就在 +New 按钮之前。但它没有显示在页面上的任何地方。我错过了什么?

这是我在阅读 SDK 后编写的示例 XML。

            <RibbonDiffXml>
            <CustomActions>
                <CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children">
                    <CommandUIDefinition>
                        <Button Id="Bee.HomepageGrid.account.GoToUrl" Command="Bee.CommandDefinition.GoToUrl" LabelText="Go To URL" ToolTipDescription="Description, Go to URL with selected account" ToolTipTitle="Title, Go to URL with selected account" />
                    </CommandUIDefinition>
                </CustomAction>
            </CustomActions>
            <Templates>
                <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
            </Templates>
            <CommandDefinitions>
                <CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
                    <EnableRules>
                        <EnableRule Id="Bee.EnableRule.SelectionCountOne" />
                    </EnableRules>
                    <DisplayRules>
                        <DisplayRule Id="Bee.DisplayRule.AllClients"/>
                    </DisplayRules>
                    <Actions>
                        <Url Address="http://localhost/mysite" PassParams="true"></Url>
                    </Actions>
                </CommandDefinition>
            </CommandDefinitions>
            <RuleDefinitions>
                <TabDisplayRules />
                <DisplayRules>
                    <DisplayRule Id="Bee.DisplayRule.AllClients">
                        <CommandClientTypeRule Type="Modern" />
                        <CommandClientTypeRule Type="Refresh" />
                        <CommandClientTypeRule Type="Legacy" />
                    </DisplayRule>
                </DisplayRules>
                <EnableRules>
                    <EnableRule Id="Bee.EnableRule.SelectionCountOne">
                        <SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
                    </EnableRule>
                </EnableRules>
            </RuleDefinitions>
            <LocLabels />
        </RibbonDiffXml>

【问题讨论】:

    标签: dynamics-crm dynamics-crm-2013


    【解决方案1】:

    我只申请了一个CommandClientTypeRule Type="Refresh",它可以工作。再次应用所有三种类型都不起作用。都有不同的含义,如下所示。

    现代:使用适用于平板电脑的 Microsoft Dynamics CRM 呈现命令栏。

    刷新:使用更新的用户界面显示命令栏。

    旧版:功能区在未更新实体的表单中或在 Microsoft Dynamics CRM for Microsoft Office Outlook 的列表视图中显示。

    <DisplayRules>
      <DisplayRule Id="Bee.DisplayRule.AllClients">    
        <CommandClientTypeRule Type="Refresh" />    
      </DisplayRule>
    </DisplayRules>
    

    但是转到网址按钮转到溢出部分意味着在下拉隐藏菜单中。

    new 按钮之前,在命令栏上显示按钮,以下是ribbonxml,它在选择一个记录时在 new 按钮之前显示按钮。

    <RibbonDiffXml>
      <CustomActions>
        <CustomAction Id="Bee.CustomAction.GoToUrl" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children"  Sequence="5">
          <CommandUIDefinition>
            <Button Id="Bee.HomepageGrid.account.GoToUrl"
                    LabelText="Go To URL"
                    ToolTipDescription="Description, Go to URL with selected account"
                    ToolTipTitle="Title, Go to URL with selected account"
                    Alt="Go to"
                    Command="Bee.CommandDefinition.GoToUrl"
                    Sequence="5" 
                    TemplateAlias="o1" />
          </CommandUIDefinition>
        </CustomAction>
      </CustomActions>
      <Templates>
        <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
      </Templates>
      <CommandDefinitions>
        <CommandDefinition Id="Bee.CommandDefinition.GoToUrl">
          <EnableRules>
            <EnableRule Id="Bee.EnableRule.SelectionCountOne" />
          </EnableRules>
          <DisplayRules>
            <DisplayRule Id="Bee.DisplayRule.AllClients"/>
          </DisplayRules>
          <Actions>
            <Url Address="http://localhost/mysite" PassParams="true"></Url>
          </Actions>
        </CommandDefinition>
      </CommandDefinitions>
      <RuleDefinitions>
        <TabDisplayRules />
        <DisplayRules>
          <DisplayRule Id="Bee.DisplayRule.AllClients">
            <CommandClientTypeRule Type="Refresh" />
          </DisplayRule>
        </DisplayRules>
        <EnableRules>
          <EnableRule Id="Bee.EnableRule.SelectionCountOne">
            <SelectionCountRule Minimum="1" Maximum="1" AppliesTo="SelectedEntity" />
          </EnableRule>
        </EnableRules>
      </RuleDefinitions>
      <LocLabels/>
    </RibbonDiffXml>
    

    【讨论】:

    • 你是对的。默认情况下,DisplayRule 中的多重规则类型由 AND 运算符绑定。这就是为什么该规则没有被验证为真的原因。为了通过 OR 运算符绑定规则类型,我们必须将它们包装在 中。顺便说一句,要在任何类型的客户端中显示按钮,我们根本不需要添加任何显示规则。
    【解决方案2】:

    我建议你试试Ribbon Workbench。您不再需要下载/提取/修改/打包/导入。一切都直接通过 Dynamics CRM 完成,无需任何 XML 知识。

    【讨论】:

    • 这对于开始和了解功能区自定义很有帮助。但我仍然更喜欢自己编写代码。它为您提供更多幕后见解。
    【解决方案3】:

    您应该将 LocLabels 添加到您的 RibbonDiffXml。属性 LabelText a.o.必须包含对这些本地化标签的引用。它们本身并不是用来保存文本的。

    在 CodePlex 上寻找一些优秀的功能区编辑器;他们会给你一个好的开始!

    【讨论】:

    • 不,这不是问题。实施指南说“虽然显示文本的功能区元素允许直接输入文本,但最佳做法是使用本地化标签来定义功能区中显示的文本”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 2017-10-04
    相关资源
    最近更新 更多