FetchXML Made Simple: Power Pages Tips for Dynamic Data Retrieval - CloudFronts

FetchXML Made Simple: Power Pages Tips for Dynamic Data Retrieval

Dynamics 365 Power Apps Portals (formerly Dynamics 365 Portals) allow organizations to securely expose CRM data to external users. However, fetching and displaying CRM records in a portal page requires more than just entity lists – it often needs custom data queries.

That’s where FetchXML comes in. FetchXML is Dynamics 365’s native XML-based query language used to retrieve data and it’s fully supported in Liquid templates within portals.

Step 1: Pre-Outline Brief

Target Audience:

  • -Team Leads
  • -CTOs
  • -CEOs

How this blog helps:

  • -Helps visualize how to fetch Dataverse data efficiently in Power Pages.
  • -Demonstrates how to create dynamic dashboards and user-specific data displays.
  • -Saves time by avoiding complex APIs for simple data retrieval.
  • -Improves portal performance and enhances user experience.

Step 2: Blog Outline

Opening:
Identify the need for FetchXML in Power Pages and its importance for developers and portal managers.

Core Content:

  • -What FetchXML is and why it matters.
  • -How to use it with Liquid templates in Power Pages.
  • -Dynamic personalization with FetchXML.
  • -Examples of FetchXML queries for portals.
  • -Best practices and performance tips.

Step 3: Blog Post

Introduction

For businesses leveraging Microsoft Power Pages, the ability to pull dynamic data from Dataverse is critical. While out-of-the-box entity lists work for simple scenarios, complex needs — such as personalized dashboards and filtered data — require custom FetchXML queries embedded in Liquid templates.

In this post, we’ll walk you through how FetchXML works in Power Pages, share examples, and provide best practices so you can deliver efficient, personalized portals.

Why This Matters

For growing businesses, service portals need more than just static lists. As the volume of data increases, the ability to dynamically query and display relevant information becomes essential to maintain performance, improve user experience, and reduce maintenance efforts.

With FetchXML in Liquid, developers can:

  • -Fetch filtered datasets easily
  • -Personalize portal content for logged-in users
  • -Avoid heavy client-side scriptingImprove load performance

Prerequisites

Before getting started, ensure:

  • -You have access to a Power Pages environment with Dataverse integration.
  • -understand basic FetchXML and Liquid templating.
  • -You can edit Portal web templates or content snippets.
  • -You have XrmToolBox (optional) for testing queries.

Understanding FetchXML

FetchXML is an XML-based query language for Dataverse. It allows you to:

  • -Filter data
  • -Sort results
  • -Join related tables
  • -Limit records returned

Example: Retrieve all active contacts:

<fetch>
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="emailaddress1" />
    <filter>
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>

Using FetchXML in Power Pages (Liquid Templates)

Here’s a basic implementation:

{% fetchxml active_contacts %}
<fetch>
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="emailaddress1" />
    <filter>
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>
{% endfetchxml %}

<ul>
  {% for c in active_contacts.results.entities %}
    <li>{{ c.fullname }} - {{ c.emailaddress1 }}</li>
  {% endfor %}
</ul>

This will execute the query and display results dynamically in your portal.

Making FetchXML Dynamic

You can make FetchXML personalized by using Liquid variables.

Example: Display cases only for the logged-in user:

{% assign loggedInUserId = user.id %}
{% fetchxml user_cases %}
<fetch>
  <entity name="incident">
    <attribute name="title" />
    <attribute name="ticketnumber" />
    <filter>
      <condition attribute="customerid" operator="eq" value="{{ loggedInUserId }}" />
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
  </entity>
</fetch>
{% endfetchxml %}

<h3>Your Active Cases</h3>
<ul>
  {% for case in user_cases.results.entities %}
    <li>{{ case.ticketnumber }} — {{ case.title }}</li>
  {% else %}
    <li>No open cases found.</li>
  {% endfor %}
</ul>

Real-World Example: Recent Cases Dashboard]

{% fetchxml recentcases %}
<fetch top="5">
  <entity name="incident">
    <attribute name="title" />
    <attribute name="caseorigincode" />
    <attribute name="createdon" />
    <filter>
      <condition attribute="statecode" operator="eq" value="0" />
    </filter>
    <order attribute="createdon" descending="true" />
  </entity>
</fetch>
{% endfetchxml %}

<h3>Recent Active Cases</h3>
<table>
  <tr>
    <th>Title</th>
    <th>Origin</th>
    <th>Created On</th>
  </tr>
  {% for c in recentcases.results.entities %}
    <tr>
      <td>{{ c.title }}</td>
      <td>{{ c.caseorigincode.label }}</td>
      <td>{{ c.createdon | date: "dd-MMM-yyyy" }}</td>
    </tr>
  {% endfor %}
</table>

Best Practices

  • -Test FetchXML in XrmToolBox first.
  • -Use <fetch top="n"> for performance.
  • -Cache queries where possible.
  • -Use. label for option set values.
  • -Keep datasets lean for portal performance.

To conclude,FetchXML in Power Pages is a powerful tool for creating customized, dynamic, and efficient portals. Start small — add a dynamic list or dashboard to your portal today. If you need expert guidance, CloudFronts can help you implement FetchXML-driven solutions tailored to your business needs.

💡 Want to learn more? Reach out to CloudFronts Technologies at transform@cloudfronts.com to explore FetchXML use cases for your portals and improve your customer experience.


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange