FetchXML Tutotorial

AND statement to WHERE clause in FETCH XML Dynamic CRM

In this article we will learn how to use AND statement to WHERE clause in FETCH XML Dynamic CRM

In this blog we will learn how to use AND statement to WHERE clause in FETCH XML Dynamic CRM
AND statement to WHERE clause in FETCH XML Dynamic CRM
The AND operators are used to filter records based on more than one condition:

The AND operator displays a record if all the conditions separated by AND are TRUE.
Syntax :

<fetch mapping="logical" version="1.0">
  <entity name="customers">
    <all-attributes />
    <filter type="and">
      <condition attribute="country" operator="eq" value="" />
      <condition attribute="city" operator="eq" value="" />
    </filter>
  </entity>
</fetch>

Customer Entity Database Record:
and-statement-clause-fetch-xml-dynamic-crm

AND Example :
Key Point:
vnks_customer:It is a logical name of entity.
vnks_country,vnks_city:It is a logical name of attribute/field.
vnks_address:It is a logical name of attribute/field.
vnks_postalcode: It is a logical name of attribute/field.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
    <entity name="vnks_customer" >
        <attribute name="vnks_name" />
        <attribute name="vnks_address" />
        <attribute name="vnks_city" />
        <attribute name="vnks_postalcode" />
        <attribute name="vnks_country" />
        <filter type="and" >
            <condition attribute="vnks_country" operator="eq" value="India" />
            <condition attribute="vnks_city" operator="eq" value="Buxar" />
        </filter>
    </entity>
</fetch>

Result:

<result>
        <vnks_name>
            Karuna
        </vnks_name>
        <vnks_address>
            Buxar
        </vnks_address>
        <vnks_city>
            Buxar
        </vnks_city>
        <vnks_postalcode>
            897645
        </vnks_postalcode>
        <vnks_country>
            India
        </vnks_country>
        <vnks_customerid>
            {0AF7F5CE-2640-EA11-A812-000D3AF02D13}
        </vnks_customerid>
    </result>
    <result>
        <vnks_name>
            Karuna
        </vnks_name>
        <vnks_address>
            Buxar
        </vnks_address>
        <vnks_city>
            Buxar
        </vnks_city>
        <vnks_postalcode>
            908767
        </vnks_postalcode>
        <vnks_country>
            India
        </vnks_country>
        <vnks_customerid>
            {D1EFDAE7-2640-EA11-A812-000D3AF02D13}
        </vnks_customerid>
    </result>

Leave a Reply

Your email address will not be published. Required fields are marked *