Blog: FetchXML Liquid Tag
FetchXML Liquid Tag

for read operations in Power Apps Portals

What is FetchXML Liquid

Liquid is a server-side template language that allows a developer to use common programming concepts, such as if statements and loops to create the underlying HTML, Javascript and CSS that make up the user interface (UI) of the portal and is what is displayed to the end user. In this article, we will review how to utilize FetchXML Liquid Tags for read operations in Microsoft Power Apps portals.

There are a few ways in Power Apps portals to read records from Microsoft Dataverse, primarily, built in lists/forms, Web API, and FetchXML. FetchXML offers a simple way to list data using liquid tags directly in the web page. These tags make up the programming logic that essentially tells the corresponding template what to do.

At the top of a web page, include the XML code, replacing the sample names with the information from your table. You can add this from within the maker experience, or in web pages in portal management, shown below.

In the maker experience:

in Portal Management:

Entity name: the table you would like to display data from
Order attribute: order by any column name
Note: The following code includes all columns, but if you would only like to include certain columns; you can specify them by replacing <all-attributes /> with <attribute name=”column1″ /> for each column.

{% fetchxml get_some_data %}
<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false”>
<entity name=”table_name”>
<all-attributes />
<order attribute=”attr1″ descending=”false” />
{% endfetchxml %}
{% assign query_results = get_some_data.results.entities %}

You can then use a for loop to iterate through the records and display the data. In this example, we list the “column1” custom column for each record in the table.

{% for result in query_results %}
{{ result.column1 }}
{% endfor %}

Two tools within liquid tags we can take advantage of are conditionals and operations. For example, let’s say we want to subtract “column2” from “column1” and display the results as a whole number, that code segment would look something like this:

{% for result in query_results %}
{{ result.column1 | minus: result.column2 | round }}
{% endfor %}

FetchXML offers a powerful way to query data within the Microsoft Dataverse and enables the ability to manipulate it using HTML, JavaScript, and CSS. It also opens more advanced possibilities for customization in displaying the data to the end-user, beyond the standard Tables and Forms that are built for Model Driven Applications. Combining the power of Dataverse with the versatility of JavaScript, Fetch XML lays the groundwork for creating a highly customized website for nearly any business need.

By improving your line of business applications with Microsoft Power Apps, you can improve productivity, security, increase application interoperability and decrease budgetary over-spend.

Building in Power Apps

The world needs great solutions. Build yours faster. Engage with us & bring all your data together with model-driven forms, views, lists, charts, and dashboards to offer more value with each interaction.

FSi Strategies is a recognized Microsoft Gold-Certified Partner, with over 20 years of experience; helping our clients successfully leverage the strategic value of technology to achieve their mission. Contact us today to learn more.

Start a conversation today.

Ask us about integrating your tools & platforms together – with architectural coherence and extensibility. Designing, implementing and supporting Modern Workplace technology is what FSi Strategies specializes in. We’ve helped hundreds of businesses implement modern security strategies in support of their missions. We invite you to discover how together, we can leverage the intelligent Cloud for the security and privacy needs of your business.