Fetchxml 获取具有当前用户作为所有者 CRM 2013 的活跃机会的联系人

Dav*_*oyt 1 dynamics-crm fetch fetchxml dynamics-crm-2011 dynamics-crm-2013

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

问题:即使在查看了我可以搜索的有关 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>
Run Code Online (Sandbox Code Playgroud)

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

Pau*_*Way 5

您已经检查了 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>
Run Code Online (Sandbox Code Playgroud)

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

我添加了一篇博客文章,为感兴趣的任何人提供一些介绍:http : //paul-way.com/crm-2013-fetchxml-improvements/