PowerApps for the CRM Person 1: Showing related entity data

3

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:

  1. Set the default value of the search input textbox to a context variable.
  2. 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.

Wrapping up

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.

Choose your Reaction!
  • Answering some questions that have been sent to me:
    1. For the subgrid view on the screen that shows the skills related to the person, I am filtering the gallery to the contact selected. My formula for the Item property of the gallery is Filter(PersonSkill,’Person ID’=displayItem.’Person ID’). In this example, PersonSkill is the table with the person/skill data, displayitem is a context variable that reflects the contact selected.
    2. For the Option 2: related page example, On the disaster details screen my formula to navigate to the update list is Navigate(UpdateList,ScreenTransition.None,{UpdateSearch:Gallery6.Selected.’Disaster Name’}). This navigates and sets a context variable on the target page caled UpdateSearch, and sets the value of it to the selected disaster record. On the update list page I’m setting the default value of the search text input to UpdateSearch, which makes the gallery be filtered by the selected disaster.

  • Love this post! I have been working with Canvas apps for a while and have only recently obtained licensing to pursue CDS and Model Driven apps. I had been trying to figure out the relationships for Model Drive app forms but struggled. I love the app that you showed. I work for the Red Cross and was at the Hack4Good at MBAS this year where folks made some awesome apps. Perhaps you were there. 🙂

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.