Apps Development, Cloud Computing

3 Mins Read

Building Advanced Filters in Model Driven Apps with FetchXML

Voiced by Amazon Polly

Introduction

The normal Advanced Find / View Editor in Power Apps can be inadequate when dealing with Model-Driven Apps, particularly when you wish to apply conditions such as:

  • filtering on nested related tables
  • OR conditions combined with AND
  • multi‑level lookups
  • conditions not supported in UI
  • complex joins across custom tables

FetchXML turns into your hidden superpower in these situations. The Power Apps platform uses FetchXML as its underlying query language for views/ charts and reports. For creating, extracting, editing, and reapplying FetchXML queries, XrmToolBox offers the most convenient and developer‑friendly approach, making it a go‑to utility for Dynamics 365 and Power Platform professionals.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Why Use FetchXML?

When you require flexibility and precision that the ordinary View Editor cannot offer, FetchXML becomes indispensable. In addition to managing intricate filters, FetchXML enables you to create more intelligent, context-aware views that automatically change according to the user, business unit, or depth of the relationship.
In contrast to the user interface, which only displays basic requirements, FetchXML allows you to:

  • Integrate clear, schema-driven reasoning into the query itself.
  • Without the need for additional fields or plugins, enforce security-aligned visibility.
  • Utilize the same query in Power Pages, Power BI, and Power Automate.
  • Maintain queries more expertly by using documentation and versioning.
  • Instead of using UI constraints, implement rules that correspond to actual business operations.

Without having to manually code XML, you may access these sophisticated features with XrmToolBox’s FetchXML Builder, a visual designer.
To put it simply: FetchXML is a method for developing robust, manageable, enterprise-grade views rather than merely a workaround.

Using XrmToolBox to Download / Edit and Upload FetchXML

Step 1 — Connect to your environment

  • Open XrmToolBox → Connect to your Dataverse environment using OAuth.
  • Ensure you have System Customizer (or equivalent) privileges.

Step 2 — Open FetchXML Builder

  • From the Tools list, install/open FetchXML Builder.
  • Click Load Entities to refresh metadata.

Step 3 — Load the view’s current FetchXML

  • In FetchXML Builder, go to Open → Load Saved Query.
  • Pick your Table → choose System View or Personal View.
  • Select the target view → Load.
    You’ll now see the underlying FetchXML.

Step 4 — Add advanced logic visually

Leverage the controls in the left navigation area to configure and adjust your FetchXML structure.

  • Add link-entity joins to related tables.
  • Create nested filter groups (and/or).
  • Add operators not exposed in UI (e.g., eq-userid, in).
  • Select attributes/columns and sort order.
  • Set aliases to avoid duplicate attribute collisions.

Pro tip: Keep joins minimal and indexed (primary keys) to avoid performance issues.

Step 5 — Validate before upload

  • Click Execute to preview results.
  • Fix alias conflicts and confirm expected row counts.
  • Save a versioned copy of the XML for audit/rollback:
    File → Save FetchXML to file.

Step 6 — Upload the updated FetchXML to the view

  • In FetchXML Builder, open View Designer.
  • Load View → Replace FetchXML with your edited query.
  • Save and Publish All Customizations.
  • Refresh your app and test.

Note: The modern Power Apps view editor doesn’t support pasting XML directly—XrmToolBox bridges that gap.

Real Life Example: Applying Complex Filters Not Possible in UI Scenario

A table of purchase orders is in your possession. Only the POs associated with their Vendor Account, which are obtained through multi-level interactions (usually found in vendor/customer portals), must be visible to each Vendor user.

Relationship path (example):

Purchase Order (custom table)

→ Vendor (Account)

→ Primary Contact (Contact)

→ User (SystemUser) of logged-in person

Goal: Show POs only when the logged‑in user is the vendor’s primary contact (or related contact).

Why UI can’t do this:

  • Multi‑level joins and user‑context operators at deeper relationship layers aren’t supported by the OOB view designer.
  • FetchXML allows precise link-entity definitions and eq-userid logic where required.

Advantages of FetchXML Based Custom View Filtering

  1. Address UI-impossible situations:
    Use multi-entity joins, nested and/or, and user-context filters without resorting to hacking.
  2. Clean Architecture:
    Steer clear of plugins, flow-based stamping, repeated lookups, and superfluous computed fields.
  3. Reusable across platform:

Model-driven views, charts/dashboards, Power Automate having List rows action, Power BI using Dataverse connector, and Power Pages can all be powered by the same FetchXML logic.

4. User-relevant and Security Aligned:

Don’t give any more/less than each person should see.

5. Versionable and maintainable:
Keep XML under source control, record modifications, and confidently roll back.

Conclusion

Don’t compromise your requirements / over-engineer adaptations when the basic view editor reaches its boundaries.

You have expressive, accurate control over data shaping with FetchXML, and the entire process, from extraction and modification to upload, is made quick, easy to see, and secure with XrmToolBox (FetchXML Builder + View Designer).

Drop a query if you have any questions regarding FetchXML and we will get back to you quickly

Empowering organizations to become ‘data driven’ enterprises with our Cloud experts.

  • Reduced infrastructure costs
  • Timely data-driven decisions
Get Started

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

FAQs

1. Can I update System Views and Personal Views with this method?

ANS: – Yes. You can load and replace FetchXML for both. System Views affect everyone; Personal Views affect only the owner.

2. What permissions do I need?

ANS: – At least System Customizer (or equivalent) to modify System Views. Personal Views require access to the table and records.

3. What are common errors to watch for?

ANS: –

  • Alias conflicts (same column name across joins)
  • Wrong relationship keys in link-entity (from/to mis‑mapped)
  • Using unsupported operators for a given data type

WRITTEN BY Ranjani Iyer Srikrishnan

Iyer Ranjani Srikrishnan is a Power Platform Developer at CloudThat, specializing in low-code business solutions using Power Apps, Power Automate, and Power BI. She builds responsive applications, automated workflows, and insightful dashboards that drive efficiency and enable data-driven decision-making. Ranjani is also skilled in JavaScript, HTML, and Power Fx, working extensively with Dataverse, SharePoint, and SQL to deliver customized, user-friendly solutions. Passionate about creating impactful digital experiences, she actively explores emerging tools such as AI Builder, Power Virtual Agents, and Azure Logic Apps to continuously enhance her expertise in the Power Platform ecosystem.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!