如何将null或空传递给FetchXML过滤器?

问题描述 投票:1回答:3

场景:我在订单类型的Dynamics CRM中有一个文本字段。该字段与其他一些系统集成在一起,它只接受已经声明的值列表;比如,ABC,IJK,XYZ等。现在我可以使用Advanced查询此字段,如果它包含数据。

现在在报告中,我有一个参数,它具有所有可能的值,另外一个参数为“不包含数据”,其值为空字符串。我还为多选项启用了此报告参数。但是,如果从报告参数中选择了任何值,我将无法获得订单。

下面是我的FetchXML查询,请让我知道下面我缺少的内容。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="invoicedetail">
   <attribute name="productid" />
    <attribute name="invoicedetailid" />
    <attribute name="tv_ordertype" />
    <order attribute="productid" descending="false" />
    <filter type="and">
        <condition attribute="tv_ordertype" operator="in" value="@Order_Types" />
    </filter>
  </entity>
</fetch>
filter dynamics-crm-2011 fetchxml
3个回答
0
投票

遗憾的是,您无法将值(“ABC”,“IJK”,“XYZ”)与空字符串选项组合在一起。想想SSRS如何将空字符串解析为FetchXml:

<condition attribute="tv_ordertype" operator="in" value="" />

因为in运算符有一个空字符串,所以没有匹配的结果。

一种可行的方法是将FetchXml更改为使用or过滤器,就像这样

<filter type="or">
    <condition attribute="tv_ordertype" operator="null" />
    <condition attribute="tv_ordertype" operator="in" value="@Order_Types" />
</filter>

现在,这将返回符合您条件的CRM中的所有值或具有null tv_ordertype

然后,您可以在Tablix / report级别应用其他过滤


-1
投票

尝试类似下面的内容

  <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
    <entity name="invoicedetail">
        <attribute name="productid" />
        <attribute name="invoicedetailid" />
        <attribute name="tv_ordertype" />
        <order attribute="productid" descending="false" />      
        <filter type='and'>         
<condition attribute="tv_ordertype" operator="in" value="@Order_Types" />
        </filter>
    </entity>
</fetch>

-1
投票

您的获取XML应如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
   <entity name="invoicedetail">
      <attribute name="productid" />
      <attribute name="invoicedetailid" />
      <attribute name="tv_ordertype" />
      <order attribute="productid" descending="false" />
      <filter type="and">
         <condition attribute="tv_ordertype" operator="in"/>
            <value>@Order_Types[0]</value>
            <value>@Order_Types[1]</value>
            <!-- etc -->
         </condition>
      </filter>
   </entity>
</fetch>
© www.soinside.com 2019 - 2024. All rights reserved.