Introduction: This blog explains how to use FetchXML to query data from Microsoft Dataverse (CDS) and display the results on a webpage in PowerApps Portal.
The Screenshot given below explains the liquid code used to display the fields of different data types.

Implementation
Create your FetchXML query and download it.

Syntax for FetchXML in liquid code is as follows:
{% fetchxml giveQueryName %}
<!— Paste your Fetchxml query -->
...
{% endfetchxml %}
- The “giveQueryName.results.entities” contains the result of fetchXML query. You can iterate through the results and get the field values.
Example:
{% fetchxml demoData %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="vv_demo">
<attribute name="vv_demoid" />
<attribute name="vv_name" />
<attribute name="createdon" />
<attribute name="vv_age" />
<attribute name="vv_author" />
<attribute name="vv_customer" />
<attribute name="vv_date" />
<attribute name="vv_description" />
<attribute name="vv_dn" />
<attribute name="vv_amount" />
<attribute name="vv_fpn" />
<attribute name="vv_interested" />
<attribute name="vv_topic" />
<order attribute="vv_name" descending="false" />
<filter type="and">
<condition attribute="vv_amount" operator="gt" value="300" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
<b>Total Records:</b> {{demoData.results.entities.size}}</br>
{% for result in demoData.results.entities %}
Record Guid: {{result.vv_demoid}}</br>
Name: {{ result.vv_name }}</br>
Description: {{ result.vv_description }} </br>
Age: {{result.vv_age}} </br>
DN: {{result.vv_dn}} </br>
FPN: {{result.vv_fpn | round: 5}} </br>
Amount: {{result.vv_amount}} </br>
Author Guid: {{result.vv_author.id}} </br>
Author Name: {{result.vv_author.name}} </br>
Topic Label: {{result.vv_topic.label}}</br>
Topic Value: {{result.vv_topic.value}}</br>
Customer Guid: {{result.vv_customer.id}} </br>
Customer Name: {{result.vv_customer.name}} </br>
{% endfor %}
- Add the above liquid code on the webpage where you want to display the result.
Follow steps given below to add the code on a webpage:
- Go to Apps and select your portal.
- Click on More commands(…) –> Edit

- Select the webpage

- Click on Source Code Editor </>

- Paste your code here and click on save

- Once you are done, Click on Browse website.

You can see the result on the webpage

NOTE:
- User should have permission to access the data
- Create an Entity Permission record and give privileges based on your requirements

- Add web roles to the entity permission

- User should have any of that web role to access the data.

I hope this blog helps you to use FetchXML in PowerApps portal. If you have any queries, you can share those in the comments section.
In Part 2 we will see how we can access data of related entity(linked entity attributes)