【问题标题】:FetchXML OR ConditionFetchXML OR 条件
【发布时间】:2011-12-31 12:07:19
【问题描述】:

我有一个 FetchXML 查询并且我有它,所以如果partitiontypemask 等于 5,它会将参与类型掩码为 5 的用户放在必填列中。但我也想添加它,所以如果用户的参与类型掩码为 6,那么它将这些用户放在可选列中。这在 FetchXML 中是否可行?这是我目前所拥有的。

<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="firstname" alias="RequiredContactFirstName" />
            <attribute name="lastname" alias="RequiredContactLastName" />
        </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>
        <filter type="and">
            <condition attribute="scheduledstart" operator="on-or-after" value="@FromDate" />
            <condition attribute="scheduledstart" operator="on-or-before" value="@ToDate" />
        </filter>
      </entity>
</fetch>

【问题讨论】:

  • 我不知道你是否明白:你想在结果中包含两个分区类型掩码吗?
  • 是的,我想包括 5 和 6 的分区类型掩码。但我希望 5s 的那些进入必需列,而 6 的那些进入可选列。谢谢!

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


【解决方案1】:

我个人一直很忙,很抱歉让您久等了,但我认为您应该做的就是使用适当的别名再次加入 link-entity Activity Party,如下所示。

<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="firstname" alias="RequiredContactFirstName" />
        <attribute name="lastname" alias="RequiredContactLastName" />
      </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" link-type="outer" alias="optionalactivityparty">
      <attribute name="participationtypemask" alias="optionalparticipationtypemask" />
      <filter>
        <condition attribute="participationtypemask" operator="eq" value="6" />
      </filter>
      <link-entity name="contact" from="contactid" to="partyid" link-type="outer" alias="optionalcontact">
        <attribute name="firstname" alias="OptionalContactFirstName" />
        <attribute name="lastname" alias="OptionalContactLastName2" />
      </link-entity>
      <link-entity name="systemuser" from="systemuserid" to="partyid" link-type="outer" alias="systemuser2">
        <attribute name="fullname" alias="OptionalOwners" />
      </link-entity>
      <link-entity name="account" from="accountid" to="partyid" link-type="outer" alias="optionalaccount">
        <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>

【讨论】:

  • 感谢您的建议。当我尝试时,我得到一个错误。错误是:“从查询集中读取数据时发生错误。(Microsoft.Crm.Reporting.DataExtension.Common.Fetch)”
  • 我必须先删除所有link-entitys 和引用您组织的自定义字段(new_contactpersonnew_coldernotes 等)的属性,然后再将查询剥离为其应包含的通用元素在每个 Dynamics 环境中执行。先尝试这样做,如果这不起作用,请告诉我们异常中是否有任何其他可用信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-13
  • 1970-01-01
  • 2014-08-09
  • 2013-11-19
  • 1970-01-01
  • 2020-12-07
相关资源
最近更新 更多