If you are like me and have worked with Dynamics 365/CRM for years, approaching PowerApps might be a little bit intimidating. Part of it is that so many things that are very easy or automatically done for us in Dynamics 365 and model-driven apps need to be manually done in canvas apps. And when you search for the answer, much of the PowerApps blog and video content is from the perspective of a developer with a non-CRM background, like SharePoint.
In this series of posts, I intend to show how to do some of these things that are common in Dynamics 365 when making a canvas app. If you don’t have a Dynamics background, hopefully you will also find some benefit from them.
Related Entity Data
When building a more complex app, you frequently have the need to work with parent/child data. Say you have companies and want to show the employees working for the company, or an event and related registrations for the event.
In Dynamics and model-driven apps, this is easy.
Every record form shows a Related tab where you can see all of the entity relationships.
We can also add a subgrid to the parent entity form to display related records in-line.
Related Entity Data in Canvas Apps
When making a Canvas App, the maker needs to add visibility of related records to the app. In this example, I’m building a canvas app for a volunteer coordinator to use to manage a disaster relief team.
First, add a data connection to each table/entity that you will include in your app.
Once you have your data connections, now you can display your related entity data in your Canvas App.
Option 1: In-line
In my app I want to show skills on the person form, similar to the experience of a subgrid in Dynamics 365. That way I can easily see the skills related to a person.
In this case I add a display form and a gallery to the same page of the app
The display form displays the selected person from a person gallery on another page of the app. The skills gallery is connected to a cross-reference table of people and related skills.
This gives users of the app a subgrid-like experience in a canvas app. Note if you want to give users the ability to create child records from the subgrid gallery, you will need to add that to your app. To do this, I added the + icon to the subgrid header, and in my expression, set a context variable on the next screen with the ID of the selected contact. This allowed me to automatically set the created person skill to Barbara.
Option 2: Related page
Sometimes you don’t want to show the related information in a subgrid. Maybe your form is more information dense and you just want to go to a full list of record. This behavior is easy to reproduce with a Canvas App. In our scenario, volunteers will send updates from the disaster site about what they have done. In my app, I already have a page that users can go to see all updates from all teams.
The Update gallery has a search text input control to search and filter the update list.
We can leverage this same page for display of related records:
- Set the default value of the search input textbox to a context variable.
- From the parent record page, add a button or icon to navigate to the related records, in the navigate formula update the context variable referenced in the search control.
Now when volunteers click the update button from the disaster page, they see a filtered list of only the updates for the selected disaster.
So is it easier to display related entity data in model-driven apps? Yes. However, once you get used to working with canvas apps and filtering galleries, you will appreciate the extra level of control that you have over the experience, and can easily display related records in your canvas app.