Canvas Apps Dataverse

How to use Dataverse views to filter related records

A coffee filter
A coffee filter

Introduction to Dataverse Views

Dataverse views are a super powerful tool. They are commonly used in model-driven apps to display a list of records based on certain filter criteria and sorted by a specific sort order. To learn more about them, click here.

Filtering using Dataverse Views

In a canvas app, Dataverse views make complex filtering (for a gallery or a data table) super easy. I covered a perfect example of this in one of my previous blog posts. In this post, I show how to filter Activities to show only tasks and appointments. This is not possible inside a canvas app because 'Activity Type' column isn't accessible in a canvas app.

The syntax for using a view to filter out Activities to only show tasks and appointments is:

Filter(
    Activities,
    'Activities (Views)'.'Filtered Activities View'
)

To learn more about this, click here.

Filtering related records using Dataverse Views

Based on the above code, you would think this code should work to show related activities (tasks and appointments) for a given account (as Items property of a gallery):

Filter(
    locSelectedAccount.Activities,
    'Activities (Views)'.'Hardit Appt & Task View'
)

where locSelectedAccount is a variable that stores the selected account.

However, you get an error with this code:

Error when using Dataverse views to filter related records
Error when using Dataverse views to filter related records

To get past this error, set the Items property of the gallery to:

Filter(
    Activities,
    Regarding = locSelectedAccount,
    'Activities (Views)'.'Hardit Appt & Task View'
)

Thus, by filtering the table of related records directly gets rid of the error that you get when using the dot operator.

Recent articles

  1. Have you played Connect 4? In Power Apps?
  2. How I made a personal trainer scheduling app
  3. Have you played Battleship? In Power Apps?

1 thought on “How to use Dataverse views to filter related records”

Leave a Reply