【问题标题】:FetchXML Query to fetch columns from multiple Linked EntityFetchXML 查询以从多个链接实体中获取列
【发布时间】:2019-11-02 02:55:59
【问题描述】:

场景:有一个在网格中显示数据的门户,这些数据来自 Dynamics 365。作为 Dynamics 开发,我被要求提供一个查询,该查询将以以下格式显示数据

例如,电话可以与联系人或 CustomAccount(自定义实体)相关联,并且 CustomAccount 在其表单上查找联系人。我们需要所有电话记录,但有一个问题。在获取联系人的电话时,我们需要获取联系人的字段值,例如住宅地址、邮寄地址、电子邮件地址、电话号码。这是可行的。但是,如果电话与 CustomAccount 实体关联,那么我们必须获取与 CustomAccount 实体关联的联系人,然后获取其字段,如住宅地址、邮寄地址、电子邮件地址、电话号码。

我尝试构建查询,但结果很奇怪,只显示与 CustomAccount 实体关联的电话,而不是联系人实体。

<fetch>
  <entity name='phonecall' >
    <all-attributes/>
    <link-entity name='contact' from='contactid' to='regardingobjectid' link-type='outer' alias='contact' >
      <all-attributes/>
    </link-entity>
    <link-entity name='pref_CustAccount' from='pref_CustAccountid' to='regardingobjectid' link-type='outer' alias='account' >
      <link-entity name='contact' from='contactid' to='lpl_clientid' link-type='inner' alias='accountcontact' >
        <all-attributes/>
      </link-entity>
    </link-entity>
  </entity>
</fetch>

【问题讨论】:

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


    【解决方案1】:

    我刚刚在我的 CRM 实例上复制了您的场景。我认为您的问题在于以下行的链接类型。

     <link-entity name='contact' from='contactid' to='lpl_clientid' link-type='inner' alias='accountcontact' >
    

    你需要外在而不是内在。 当我给 inner 时,我只得到与上述行相关的那些记录。

    这是我的完整获取

    <fetch>
      <entity name="phonecall" >
        <link-entity name="contact" from="contactid" to="regardingobjectid" link-type="outer" alias="directcontact" >
          <attribute name="fullname" />
        </link-entity>
        <link-entity name="account" from="accountid" to="regardingobjectid" link-type="outer" alias="account" >
          <link-entity name="contact" from="contactid" to="primarycontactid" link-type="outer" alias="primarycontact" >
            <attribute name="fullname" />
          </link-entity>
        </link-entity>
      </entity>
    </fetch>
    

    【讨论】:

      猜你喜欢
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 1970-01-01
      • 2020-10-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多