我有一个FetchXML查询,我有它,所以如果participanttypemask等于5,那么它会将参数类型掩码为5的用户放入必需列中。但我也想添加它,所以如果用户的参与类型掩码为6,那么它会将这些用户放在Optional列中。这在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>
答案 0 :(得分:0)
我个人一直很忙,很抱歉等待时间较长,但我认为您应该做的就是使用适当的别名再次加入link-entity
Activity Party
,如下所示。< / p>
<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>