Power Platform – Creating Relationships between Entities and create a Canvas App using Common Data Service (CDS)

Hi Everyone,

We discussed in our last article about Creating Entities in Common Data Service (CDS)https://knowledge-junction.com/2020/07/02/power-platform-creating-entities-in-common-data-servicecds/ . Now let’s begin with relationships and create a canvas app using CDS.

What is mean by Relationships?

Entity records can be associates with records of other entity or same entity. In simple words one entity data relates (relation) to other entity data

For example we have Team Leads entity and Developers entity where Developers entity has lookup relationship to the Team Leads entity to show which developer work under which team lead person. You can use a lookup field to show data from the Team Leads entity.

We can create several types of relationships from one entity to another (or between an entity and itself). Each entity can have a relationship with more than one entity, and each entity can have more than one relationship to another entity.

There are some relationships types are:-

1. One-to-many – In this type of relationship, each record in entity A can match only one record in entity B but each record in entity B can match more than one record in entity A. For example single team lead work with more than one developer.

2. Many-to-one – In this type of relationship, each record in entity A can match many record in entity B but entity B can match only one record in entity A. For example a many project handle by one company.

3. Many-to-many – In this type of relationship, each record in entity A can match more than one record in entity B and vice versa. For example, students attend many classes, and each class can have multiple students.

Creating relationship for entity

  1. Now open https://make.powerapps.com on left navigation pane select Data -> Entities
  2. Used existing or create new entity as we discussed in previous article https://knowledge-junction.com/2020/07/02/power-platform-creating-entities-in-common-data-servicecds/ .
  3. Select your created entity from list and click on Relationships tab.
  4. Click on “+ Add relationship”
Fig.1 Power Platform – Power Apps – Creating Relationship

5. Now select type of relationship from drop down, we are selecting + Many -to-one.

Fig.2 Power Platform – Power Apps – Selecting relations type

6. Now select Related (One) -> Account from list, you can select any entity from drop down which we want to lookup relationship and click on Done.

Fig.3 Power Platform – Power Apps – Lookup relationship with Account

7. When we done with this all steps then Account field with data type lookup automatically added to the list of fields.

Fig.4 Power Platform – Power Apps – Account field added in list

We are done with creating relationships now time to create a Canvas App.

Creating Canvas App using Common Data Service

  1. Now open https://make.powerapps.com or from left navigation pane select Home.
  2. Select Start from data-> Common Data Service.
  3. Connection window opens then select “+ New connection”.
Fig.5 Power Platform – Power Apps – New Connection

4. Select Common Data Service from My connections and click on Create.

Fig.6 Power Platform – Power Apps – Create Common Data Service Connection

5. Choose a table or entity from list and click on Connect. We are going to select our created entity as we see in previous article https://knowledge-junction.com/2020/07/02/power-platform-creating-entities-in-common-data-servicecds/.

6. Welcome window pop up please skip it and PowerApps studio page opens.

7. There are three screens as we can see on left navigation pane Tree View-> Screens tab.

Fig.7 Power Platform – Power Apps – PowerApps studio page

8. On the home tab you can see New Screen select the down arrow and select List from drop down list, we are adding list.

Fig.8 Power Platform – Power Apps – Creating list screen

9. Now screen is added with several default controls such as search and gallery control which covers all screens under search box.

10. Click on Screen1-> BrowseGallery2 and select data source as table name or entity name or on your right – hand pane of BrowseGallery2 Properties tab select Data source as a table name or entity then select Layout and from drop down list select title, subtitle and body.

Fig.9 Power Platform – Power Apps – Select data source

11. Select Fields -> Edit and add data as Body1 -> Address , Subtitle1 -> MobileNo and Title1 -> EmpName.

Fig.10 Power Platform – Power Apps – BrowseGallery property window

12. We will delete and rename form by clicking on ellipsis(…) rename of Screen1 to ViewScreen and EditScreen1 to EditScreen .

Fig.11 Power Platform – Power Apps – Delete and Rename Options

13. On Record ViewScreen select circular-arrow icon set the OnSelect property to formula Refresh(Employees). When user selects this icon, the data from Employees is refreshed from the data.

Fig.12 Power Platform – Power Apps – Editing formula bar

14. Now select Plus “+” icon and set OnSelect property to formula “NewForm(EditScreen);Navigate(EditScreen,ScreenTransition.None)”. When user click on plus sign Edit Form opens and we will add new records in data. Change label [Title] to Employees of ViewScreen.

15. Select right side arrow of records in the gallery and set the OnSelect property by this formula “EditForm(EditForm1); Navigate(EditScreen, ScreenTransition.None)”.When user click on arrow Edit Form opens in which user edit, update and delete records.

Fig.13 Power Platform – Power Apps – Applying function on OnSelect property

16. Select EditForm from left navigation pane.

17. Now on right hand pane select Properties-> Edit fields and click on +Add field and check all columns from drop down list.

Fig.14 Power Platform – Power Apps – Add field Page

18. Select cross sign of the page near left side to the page title and set OnSelect Property by this formula ResetForm(EditForm1);Navigate(ViewScreen,ScreenTransition.None). When user click on cross sign its redirected to ViewScreen page.

19. Now select on checkmark sign near right side to title and set OnSelect property by this function SubmitForm(EditForm1);Navigate(ViewScreen,ScreenTransition.None). When user click on sign the changes made by user is saved and redirected to ViewScreen page.

20. For Testing the app press the play button.

21. Now we will Save , update and delete records from Common Data Service using canvas app from PowerApp.

Thanks for reading. If it’s worth at least reading once, kindly like and share. STAY SAFE STAY HEALTHY.

2 thoughts on “Power Platform – Creating Relationships between Entities and create a Canvas App using Common Data Service (CDS)

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