【问题标题】:Fetchxml to get contacts with active opportunities having the current user as owner CRM 2013Fetchxml 以获取具有当前用户作为所有者 CRM 2013 的活跃机会的联系人
【发布时间】:2014-05-21 15:16:22
【问题描述】:

目标:制作一个可以显示当前用户拥有的所有联系人以及当前用户拥有的具有相关机会的任何联系人的视图。

问题:即使在查看了我可以通过 Google 搜索到的内容后,我也没有很好的 fetchxml 或链接实体命令。当我尝试使用我的 fetch 语句构建视图时,它没有带回任何东西,所以我认为我构建它不正确。

这是我到目前为止所做的声明:

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
                    <entity name='contact'>
                      //big list of attributes
                      <order attribute='fullname' descending='false' />
                      <link-entity name='opportunity' from='customerid' to='contactid' alias='aa'>
                       <filter type='and'>
                         <condition attribute='ownerid' operator='eq-userid' />
                       </filter>
                      </link-entity>
                      <filter type='or'>
                        <condition attribute='ownerid' operator='eq-userid' />
                      </filter>
                    </entity>
                </fetch>

任何提示将不胜感激,谢谢!

【问题讨论】:

  • 你是在 fetchXml 查询之后吗?
  • 一个全新的,或了解我的可能有什么问题。无论哪种方式。

标签: dynamics-crm-2011 dynamics-crm fetch dynamics-crm-2013 fetchxml


【解决方案1】:

您已经检查了 CRM 2011 和 CRM 2013。使用 CRM 2011,这是不可能的。借助 CRM 2013,您可以做到这一点!

<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='contact'>
    <attribute name='fullname' />
    <order attribute='fullname' descending='false' />
    <link-entity name='opportunity' from='customerid' to='contactid' alias='aa' link-type='outer'>
        <attribute name='name' />
    </link-entity>
    <filter type='or'>
        <condition attribute='ownerid' operator='eq-userid' />
        <condition entityname='aa' attribute='ownerid' operator='eq-userid' />
    </filter>
</entity>
</fetch>

您会注意到,过滤器中引用了别名,您必须使用外连接。

我添加了一篇博文,为有兴趣的人提供一些指导:http://paul-way.com/crm-2013-fetchxml-improvements/

【讨论】:

  • 您在建议之前尝试过您的代码吗?我试过了,我得到了“无效的 XML”。例外。
  • 是的,它对我来说在 CRM 2013 在线上运行良好。这在 2011 年无效;你在哪里运行它?
  • 在 6.0.2.50 上成功运行。您测试的在线实例版本是什么?
  • 好的,再试一次。未显示结束 fetch 语句。
  • 现在可以了。非常有趣的功能,它可能很有用。谢谢!
【解决方案2】:

很遗憾,您无法使用 FetchXml 构建此查询。解决方法是构建报告并将其嵌入到您的 CRM 中。

【讨论】:

    【解决方案3】:
    <fetch distinct="false" no-lock="false" mapping="logical">
      <entity name="contact">
        <attribute name="fullname" />
        <filter type="and">
          <filter type="and">
            <condition attribute="ownerid" operator="eq" value="{00000000-0000-0000-0000-000000000000}" />
            <filter type="and">
              <condition attribute="statecode" operator="eq" value="0" />
              <condition attribute="statecode" operator="eq" value="0" />
            </filter>
          </filter>
        </filter>
        <link-entity name="opportunity" to="contactid" from="contactid" link-type="inner" alias="o_0" />
      </entity>
    </fetch>
    

    00000000-0000-0000-0000-000000000000 替换为当前用户Guid。

    【讨论】:

      【解决方案4】:

      我不是 FetchXML 专家,但我认为这个查询是不可能的。

      这是 CRM 的解释:

      相关实体条件或组不能与父级分组 实体条件或组

      【讨论】:

      • 经过更多的搜索和实验,这基本上也是我得出的结论。它似乎几乎可以归结为链接实体功能,如“和”过滤器。我需要它像“或”过滤器一样工作。很好。
      猜你喜欢
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      相关资源
      最近更新 更多