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:
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.
1 thought on “How to use Dataverse views to filter related records”