FetchXML Tutotorial

fetchxml WHERE Clause in dynamic crm

In this article we will learn how to use fetchxml WHERE Clause in dynamic crm ?

fetchxml WHERE Clause in dynamic crm
The WHERE clause is used to filter records. The WHERE clause is used to extract only those records that fulfill a specified condition.

Syntax:
[php]
<fetch mapping="logical" version="1.0">
<entity name="xyz">
<all-attributes />
<filter>
<condition attribute="country" operator="eq" value="yzz" />
</filter>
</entity>
</fetch>
[/php]

fetchxml WHERE Clause Example
Key Point:
vnks_customer:It is a logical name of entity.
vnks_name:It is a logical name of attribute/field.
vnks_country:It is a logical name of attribute/field.
vnks_city:It is a logical name of attribute/field.
vnks_postalcode:It is a logical name of attribute/field.
[php]
<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" />
</filter>
</entity>
</fetch>
[/php]

Result: After excute this fetchxml query
[php]
<result>
<vnks_name>
Kishan Yadav
</vnks_name>
<vnks_address>
Varansai
</vnks_address>
<vnks_city>
Varanasi
</vnks_city>
<vnks_postalcode>
23457
</vnks_postalcode>
<vnks_country>
India
</vnks_country>
<vnks_customerid>
{DEBBC9B8-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>
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
[/php]

Leave a Reply

Your email address will not be published.