Power Pages, FetchXML and Liquid: Group results by Lookup fields

When we run FetchXML queries on Power Pages Liquid code we get the results as a single table data structure. But sometimes it would be useful if we could group the results by some of the fields on the data set before rendering the items on the page, so we can use that for some calculations or to render data in a structure that is not a table structure or flat data structure display, like a hierarchy view for instance.

We can do it easily by using the group_by Liquid filter and the correct syntax.

Example scenario

For example, for the following data set, where we have a table named submissions and each submission is assigned to an Account:

If we want to render the following page, with the Account names as h2 heading elements, and below it an unordered list (ul) tag with the submissions listed as list item (li) items for each account:

Given that we have the following FetchXml query on the page or WebTemplate:

{% fetchxml fetch_submissions %}
<fetch…

Source link

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *