FetchXML queries
The plugin previously known as Dataverse Integration has been renamed to DataPress. This change reflects our commitment to enhancing user experience and aligning with our evolving product vision. All references to Dataverse Integration in the documentation, user interface will be updated to DataPress.
Use the powerful FetchXML query language in Twig to reflect your Common Data Service / Dynamics 365 data in WordPress.
Introduction
FetchXML is a query language used in Common Data Service to retrieve table rows using a set of conditions. DataPress (Dataverse Integration) brings support of FetchXML into Twig to allow rendering collections of CRM records or individual records on WordPress pages.
Please refer to the Microsoft Docs portal to learn about constructing FetchXML queries.
Query data using FetchXML in Twig templates
DataPress (Dataverse Integration) provides a new Twig tag, {% fetchxml %}
, which is accompanied by the required closing {% endfetchxml %}
tag. Use the required collection
column to specify the variable you will use to access retrieved records. Write your FetchXML query inside these tags. Use the optional cache
attribute to enable query cache -- please adhere to the ISO 8601 duration specification.
{% fetchxml collection="customers" cache="PT30M" %}
<fetch mapping='logical' returntotalrecordcount='true'>
<entity name='account'>
<attribute name='accountid'/>
<attribute name='name'/>
</entity>
</fetch>
{% endfetchxml %}
Collection structure
The returned collection contains several members:
xml
-- FetchXML query that was sent to Dataverse.error
-- error message, null if no errors.results
-- an object that contains results of the query.entities
-- array of retrieved Entity objectstotal_record_count
-- total count of rows that much the conditions, i.e. without imposed pagination limits. You must setreturntotalrecordcount="true"
to receive the row count. See sample FetchXML with this parameter set.more_records
-- whether more rows are available while paginating.paging_cookie
-- paging cookie for pagination, see Microsoft Docs.