FetchXML Tutotorial

What Is FetchXML ?

FetchXML is a query language that is used in Common Data Service. It’s based on a schema that describes the capabilities of the language. The FetchXML language supports similar query capabilities as query expressions. In addition, it’s used as a serialized form of query, used to save a query as a user-owned saved view in the UserQuery Entity and as an organization-owned saved view in the SavedQuery Entity.

FetchXML is proprietary query language used in Microsodt Dynamics CRM online or on-premises. It is used to retrieve records from an entity.

The following fetchxml query, selects the “CustomerName” and “City” columns from the “Customers” Entity:
Key Point:
cr685_customers – It is a logical name of customers.
[php]
<fetch mapping="logical" version="1.0" >
<entity name="cr685_customers" >
<attribute name="cr685_customername" />
<attribute name="cr685_city" />
</entity>
</fetch>
[/php]

After run this query you will get all customername and city from Customers Entity.You can also use XRM Toolbox for test your query.
Result
[php]
<result>
<cr685_customername>Rajesh Kumar</cr685_customername>
<cr685_city>Varanasi</cr685_city>
<cr685_customersid>{67D05991-A5B5-E911-A97A-000D3AF06590}</cr685_customersid>
</result>
<result>
<cr685_customername>Mahesh Singh</cr685_customername>
<cr685_city>BUXAR</cr685_city>
<cr685_customersid>{F2E6CEDA-A5B5-E911-A97A-000D3AF06590}</cr685_customersid>
</result>

[/php]

Leave a Reply

Your email address will not be published.