0

As I need to create a query where I need to add a filter condition where valid entitytype could be any from e1,e2,e3.

For that I have currently written below FetchXML:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
  <entity name="changelog" >
    <filter type="and" >
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="event" operator="eq" value="Delete" />
      <filter type="or" >
        <condition attribute="entitytype" operator="eq" value="email" />
        <condition attribute="entitytype" operator="eq" value="fax" />
        <condition attribute="entitytype" operator="eq" value="letter" />
        <condition attribute="entitytype" operator="eq" value="phonecall" />
      </filter>
    </filter>
    <order attribute="statuscode" />
    <order attribute="event" />
    <order attribute="createdon" />
  </entity>
</fetch>

Above query is passing the expected records.

But, I believe there could be another approach for this too - by using IN operator for the entitytype condition.

To test that query I am using XRMTool's FetchXML Tester which is throwing an error. The query is as below:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
  <entity name="changelog" >
    <filter type="and" >
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="event" operator="eq" value="Delete" />
            <condition attribute="entitytype" operator="in" >
                <value>
                    phonecall
                </value>
                <value>
                    email
                </value>
                <value>
                    fax
                </value>
                <value>
                    letter
                </value>
            </condition>
        </filter>
        <order attribute="statuscode" />
        <order attribute="event" />
        <order attribute="createdon" />
    </entity>
</fetch>

Above query is not returning any records as a result.

Note: I have formatted this using the FetchXML Testers' Format button.

Any help?

I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216

1 Answers1

0

The reason was the default format option provided by FetchXML Tester.

The way it was formatting the FetchXML was the reason it was not returning any value.

It is supposed to be formatted as below:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" top="5000">
  <entity name="changelog" >
    <filter type="and" >
      <condition attribute="statecode" operator="eq" value="0" />
      <condition attribute="event" operator="eq" value="Delete" />
            <condition attribute="entitytype" operator="in" >
                 <value>phonecall</value>
                 <value>email</value>
                 <value>fax</value>
                 <value>letter</value>
            </condition>
        </filter>
        <order attribute="statuscode" />
        <order attribute="event" />
        <order attribute="createdon" />
    </entity>
</fetch>
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216