使用外连接查询 CRM 2011

发布于 2024-12-19 17:25:16 字数 3079 浏览 1 评论 0原文

我使用下面的代码来查询 CRM 2011 中设置的约会。当我使用此查询时,它会返回数据,但会返回重复项。如果我取出外连接,它根本不会返回任何内容。关于如何解决这个问题有什么想法吗?

<fetch>
  <entity name="appointment">
    <attribute name="scheduledstart" />
    <link-entity name="systemuser" from="systemuserid" to="ownerid" link-type="outer">
      <attribute name="firstname" alias="ownerFirstName" />
      <attribute name="lastname" alias="ownerLastName" />
    </link-entity>
    <link-entity name="contact" from="contactid" to="new_contactperson" link-type="outer">
      <attribute name="parentcustomerid" alias="parentaccount" />
      <attribute name="new_businessunit" alias="businessunit" />
    </link-entity>
    <attribute name="new_contactperson" />
    <attribute name="subject" />
    <attribute name="new_coldernotes" />
    <link-entity name="activityparty" from="activityid" to="activityid" link-type="outer">
      <attribute name="participationtypemask" alias="participationtypemask" />
      <filter>
        <condition attribute="participationtypemask" operator="eq" value="5" />
      </filter>
      <link-entity name="contact" from="contactid" to="partyid" link-type="outer">
        <attribute name="fullname" alias="RequiredContactFullName" />
      </link-entity>
      <link-entity name="systemuser" from="systemuserid" to="partyid" link-type="outer">
        <attribute name="fullname" alias="RequiredOwners" />
      </link-entity>
      <link-entity name="account" from="accountid" to="partyid" link-type="outer">
        <attribute name="name" alias="RequiredAccount" />
      </link-entity>
    </link-entity>
    <!--the new join-->
    <link-entity name="activityparty" from="activityid" to="activityid" alias="optionalactivityparty" link-type="outer">
      <attribute name="participationtypemask" alias="optionalparticipationtypemask" />
      <filter>
        <condition attribute="participationtypemask" operator="eq" value="6" />
      </filter>
      <link-entity name="contact" from="contactid" to="partyid" alias="optionalcontact" link-type="outer">
        <attribute name="fullname" alias="OptionalContactFullName" />
      </link-entity>
      <link-entity name="systemuser" from="systemuserid" to="partyid" alias="systemuser2" link-type="outer">
        <attribute name="fullname" alias="OptionalOwners" />
      </link-entity>
      <link-entity name="account" from="accountid" to="partyid" alias="optionalaccount" link-type="outer">
        <attribute name="name" alias="OptionalAccount" />
      </link-entity>
    </link-entity>
    <filter type="and">
      <condition attribute="scheduledstart" operator="on-or-after" value="@FromDate" />
      <condition attribute="scheduledstart" operator="on-or-before" value="@ToDate" />
    </filter>
  </entity>
</fetch>

谢谢!

I am using the code below to query the appointment set in CRM 2011. When I use this query it returns the data, but it returns duplicates. If I take out the Outer joins it doesn't return anything at all. Any ideas on how to fix this?

<fetch>
  <entity name="appointment">
    <attribute name="scheduledstart" />
    <link-entity name="systemuser" from="systemuserid" to="ownerid" link-type="outer">
      <attribute name="firstname" alias="ownerFirstName" />
      <attribute name="lastname" alias="ownerLastName" />
    </link-entity>
    <link-entity name="contact" from="contactid" to="new_contactperson" link-type="outer">
      <attribute name="parentcustomerid" alias="parentaccount" />
      <attribute name="new_businessunit" alias="businessunit" />
    </link-entity>
    <attribute name="new_contactperson" />
    <attribute name="subject" />
    <attribute name="new_coldernotes" />
    <link-entity name="activityparty" from="activityid" to="activityid" link-type="outer">
      <attribute name="participationtypemask" alias="participationtypemask" />
      <filter>
        <condition attribute="participationtypemask" operator="eq" value="5" />
      </filter>
      <link-entity name="contact" from="contactid" to="partyid" link-type="outer">
        <attribute name="fullname" alias="RequiredContactFullName" />
      </link-entity>
      <link-entity name="systemuser" from="systemuserid" to="partyid" link-type="outer">
        <attribute name="fullname" alias="RequiredOwners" />
      </link-entity>
      <link-entity name="account" from="accountid" to="partyid" link-type="outer">
        <attribute name="name" alias="RequiredAccount" />
      </link-entity>
    </link-entity>
    <!--the new join-->
    <link-entity name="activityparty" from="activityid" to="activityid" alias="optionalactivityparty" link-type="outer">
      <attribute name="participationtypemask" alias="optionalparticipationtypemask" />
      <filter>
        <condition attribute="participationtypemask" operator="eq" value="6" />
      </filter>
      <link-entity name="contact" from="contactid" to="partyid" alias="optionalcontact" link-type="outer">
        <attribute name="fullname" alias="OptionalContactFullName" />
      </link-entity>
      <link-entity name="systemuser" from="systemuserid" to="partyid" alias="systemuser2" link-type="outer">
        <attribute name="fullname" alias="OptionalOwners" />
      </link-entity>
      <link-entity name="account" from="accountid" to="partyid" alias="optionalaccount" link-type="outer">
        <attribute name="name" alias="OptionalAccount" />
      </link-entity>
    </link-entity>
    <filter type="and">
      <condition attribute="scheduledstart" operator="on-or-after" value="@FromDate" />
      <condition attribute="scheduledstart" operator="on-or-before" value="@ToDate" />
    </filter>
  </entity>
</fetch>

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的痛♀有谁懂 2024-12-26 17:25:16

尝试通过将根获取节点更改为来表明您想要一个不同的记录集

<fetch distinct='true'>
...
</fetch>

Try indicating that you want a distinct record set by changing your root fetch node to

<fetch distinct='true'>
...
</fetch>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文