3

Scenario: I've a text field in Dynamics CRM on Order Type. This field is integrated with some other systems and it'll be accepting only already stated list of values; like, ABC, IJK, XYZ etc. Now I can query this field using Advanced find if it contain data or not.

Now in report, I've a parameter that is having all those possible value and one additional as "Does not contain data" and its value is empty string. I've also enabled this report parameter for multi-select. But I am unable to get the orders if any of the value is selected from report parameters.

Below is my FetchXML query, Please let me know what I am missing in below.

<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>
jasonscript
  • 6,039
  • 3
  • 28
  • 43
Mohsin A.
  • 153
  • 2
  • 18

3 Answers3

1

Unfortunately you cannot combine the values ("ABC", "IJK", "XYZ") with an empty string option. Think about how SSRS will parse the empty string into FetchXml:

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

Because the in operator has an empty string, there will be no matching results.

One approach that might work is to change your FetchXml to use an or filter, like this

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

This will now return all values from CRM that match your criteria OR have a null tv_ordertype

Then you can apply additional filtering at the tablix / report level

jasonscript
  • 6,039
  • 3
  • 28
  • 43
-1

Try something like below

  <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>
AnkUser
  • 5,421
  • 2
  • 9
  • 25
  • it don't work out for me and ended up on error: `The FetchXML parameter "@Order_Types" cannot obtain multiple values. Change Parameter "@Order_Types" to single value parameter and try again` – Mohsin A. Apr 10 '19 at 14:00
  • I updated my answer, Does your parameter get all the Order_Types? Can you post screenshot of your Parameter and your Query. Ref Link https://nishantrana.me/2016/03/04/sample-fetch-xml-report-using-multivalued-parameter-in-operator-in-crm/ – AnkUser Apr 10 '19 at 14:15
-1

Your fetch XML should look like this:

<?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>
Zach Mast
  • 1,698
  • 1
  • 10
  • 17